Opened 16 years ago

Closed 14 years ago

#2180 closed New Feature (fixed)

Display simple textarea if javascript is disabled

Reported by: Wiktor Walc Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Confirmed Cc:

Description

If javascript is disabled in FCKeditor compatible browser, most of the time nothing appears to the end user (neither FCKeditor nor simple textarea).

The only example that works with javascript disabled is sample02.html.

I belive that many people use server side integration and are unaware of this problem. Below is a simple work-around for this issue:

public function CreateHtml()
{
	$HtmlValue = htmlspecialchars( $this->Value ) ;

	$Html = '' ;

	if ( strpos( $this->Width, '%' ) === false )
	$WidthCSS = $this->Width . 'px' ;
	else
	$WidthCSS = $this->Width ;

	if ( strpos( $this->Height, '%' ) === false )
	$HeightCSS = $this->Height . 'px' ;
	else
	$HeightCSS = $this->Height ;

	if ( $this->IsCompatible() )
	{
		if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
		$File = 'fckeditor.original.html' ;
		else
		$File = 'fckeditor.html' ;

		$Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;

		if ( $this->ToolbarSet != '' )
		$Link .= "&Toolbar={$this->ToolbarSet}" ;

		// Render the linked hidden field.
		$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ;

		// Render the configurations hidden field.
		$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ;

		// Render the editor IFRAME.
		$Html .= "<iframe style=\"display:none\" id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ;

		// If JavaScript is enabled, make iframe above visible
		$Html .= "<script type=\"text/javascript\">" ;
		$Html .= "<!--\n";
		$Html .= "document.getElementById('{$this->InstanceName}___Frame').style.display='';";
		$Html .= "\n//-->";
		$Html .= "</script>" ;

		//If JavaScript is disabled, display simple textarea and leave iframe invisible
		$Html .= "<noscript>";
		$Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
		$Html .= "</noscript>" ;
	}
	else
	{
		$Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
	}

	return $Html ;
}

I know it's ugly but it seems to work. The problem is that the same value ($HtmlValue) is posted twice for textarea and hidden field. I'm not sure whether there is a way to copy this value from textarea in <noscript> tag to a hidden field.

Do you have any other proposals?

Change History (3)

comment:1 Changed 16 years ago by Alfonso Martínez de Lizarrondo

You can find another proposal (for an older version) in #1611.

I guess that it should be dupped against this one.

comment:2 Changed 16 years ago by Wiktor Walc

Simple textarea should be displayed also if displaying images is disabled in the web browser (e.g in IE nothing appears in such case).

comment:3 Changed 14 years ago by Alfonso Martínez de Lizarrondo

Resolution: fixed
Status: newclosed

This is working in CKEditor.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy