Script funktioniert im IE nicht im Firefox

Status
Nicht offen für weitere Antworten.

searching_rik

Grünschnabel
Hallo alle miteinander,

mein Problem bezieht sich auf den folgenden Code.
Ich habe hier mittels dieses Forum und Dank der con-f-usen Hilfe ein Script hinbekommen, dass eine Textdatei ausliest und diese in einer Art Richtext Editor darstellt. Das funktioniert leider nur im Internetexplorer und nicht im Firefox.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>online-editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="AUTHOR" content="con-f-use@gmx.net" />
<link rel="stylesheet" href="../css/seventhlife.css" type="text/css">
<script type="text/javascript">
	//coded by con-f-use@gmx.net - be fair and do not remove this
	var	formu, ifrm, uagent=navigator.userAgent.toLowerCase(),
		isGecko = ( uagent.match('gecko') && navigator.productSub>=20030210 ),
		isIE = uagent.match('msie') && !uagent.match('opera') && (!uagent.match('msie 5.5')||!uagent.match('msie 6.'));

	function initEdit(strFormu,strEdit) {
		formu = document.getElementById(strFormu);
		if (isIE)
			ifrm = eval('window.'+ strEdit +'.document');
		if (isGecko) {
			ifrm = document.getElementById(strEdit).contentWindow.document;
			ifrm.focus = new Function('fx','window.'+ strEdit +'.focus()');
		}
		ifrm.designMode = 'on';
		var kids = document.getElementsByTagName('div');
		for (var i=0; i<kids.length; i++)
			if (kids[i].className == 'imagebutton')
				kids[i].onclick = tbclick;
	}

	function tbclick() {
		var id = this.id;
		if(id == 'CreateLink' && isIE) {
			ifrm.execCommand(id); 
		} else {
			if (id=='FontName' || id=='FontSize') {
				sel = document.getElementById(id).childNodes;
				if (isIE) sel = sel[0];
				if (isGecko) sel = sel[1];
				arg = sel.options[sel.selectedIndex].firstChild.data; } 
			else if (id == 'InsertImage')
				arg = prompt('Enter a image location:', 'http://');
			else if (id == 'CreateLink')
				arg = prompt('Enter a URL:','http://')
			else 
				arg = null;
			ifrm.execCommand(id,false,arg);
			if (arg == null) ifrm.focus();
		}
	}

	function processData() {
		formu.content.value = ifrm.body.innerHTML;
		contents = contents.replace(/\r\n/g, '<br>');
	    contents = contents.replace(/\n/g, '<br>');
	    contents = contents.replace(/\r/g, '<br>');
  		if( !formu.content.value.replace(/<br>|\s|&nbsp;/ig,'') ) {
			alert('You did not enter any Text!');
			return false;
		}
		return true;
	}
</script>
</head>
<body onLoad="initEdit('form_content','edit')" class="t11" >
<form onSubmit="return processData()" id="form_content" action="text_write.php" method="post">
	<input type="hidden" name="var1" value= "<?php echo $vartxt; ?>">
	  <table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
    	<tr> 
      	<td width="100"> 
        <div class="imagebutton" id="bold" onClick="tbclick()"> 
			<a href="#" onClick="return false" style="font-weight:bold">
				<img src="images/ed_format_bold.gif" width="18" height="18" border="0" />
			</a>
		</div>
        </td>
        <td width="100">
		<div class="imagebutton" id="italic">
			<a href="#" onClick="return false" style="font-style:italic">
				<img src="images/ed_format_italic.gif" width="18" height="18" border="0" />
			</a>
		</div>
        </td>
        <td width="100"> 
        <div class="imagebutton" id="underline"> 
			<a href="#" onClick="return false" style="text-decoration:underline">
				<img src="images/ed_format_underline.gif" width="18" height="18" border="0" />
			</a>
		</div>
        </td>
        <td width="100"> 
        <div class="imagebutton" id="insertorderedlist">
			<a href="#" onClick="return false">
				<img src="images/ed_list_num.gif" width="18" height="18" border="0" />
			</a>
		</div>
        </td>
        <td width="100"> 
        <div class="imagebutton" id="insertunorderedlist"> 
			<a href="#" onClick="return false"> 
          		<img src="images/ed_list_bullet.gif" width="18" height="18" border="0" />
			</a>
		</div>
        </td>
        <td width="100"> 
        <div class="imagebutton" id="CreateLink"> 
			<a href="#" onClick="return false">
				<img src="images/ed_link.gif" width="18" height="18" border="0" />
			</a>
		</div>
		</td>
        </tr>
      </table>
      	<br />
	  	<iframe id="edit" name="edit" src="<?php echo $vartxt; ?>" width="100%" height="400" frameborder="0" marginheight="0" marginwidth="0">
		</iframe>
		<br />
		<input type="submit" value="Speichern">
		<textarea name="content" wrap="PHYSICAL" style="visibility:hidden;"></textarea>
		<br />
	</form>
</body>
</html>

Kann mir jemand von euch helfen auch dieses Problem zu beheben.

Vielen Dank im Voraus!
 
Status
Nicht offen für weitere Antworten.

Neue Beiträge

Zurück