|
I have a html with one button,when clicking a showModalDialog html popup which is a web text editor, in the popup html, there is a IFRAME,i use the IFRAME to save the editting text. All function will be ok in the IE5.
but in ie5.5 or lator, the IFRAME can not edit.if i use a div instead of IFRAME, it can not run on IE5.0.
here is the test html
<SCRIPT LANGUAGE=JavaScript>
function multi_edit() {
var arr = showModalDialog("editor.html?time=1063664813174", "", "dialogWidth:40em; dialogHeight:30em; status:0");
}
</SCRIPT>
<input type=button name=test value=test onclick="multi_edit()">
here is the editor html
html>
<head>
<title>ͼÎÄ»ìÅÅ</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
</head>
<body bgcolor=menu onload="InitDocument();" STYLE="margin:0pt;padding:0pt">
<input type="hidden" name="HtmlText" value='hdsfdffsd'>
<IFRAME class="Composition" ID="Composition"
MARGINHEIGHT="1" MARGINWIDTH="1" width="100%" height="320">
</IFRAME>
<script LANGUAGE="Javascript">
var bodyTag="<head><style type=\"text/css\">body {font-size: 10.8pt}</style><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"></head><BODY bgcolor=\"#FFFFFF\" MONOSPACE>"
+ document.all("HtmlText").value;
var isHTMLMode = false
function document.onreadystatechange() {
Composition.document.designMode="On";
}
function InitDocument()
{
document.designMode="On";
Composition.document.open();
Composition.document.write(bodyTag);
Composition.document.designMode="On";
// Composition.document.close();
Composition.focus();
// setTimeout("Composition.focus()",0);
}
</script>
<table>
<tr>
<td width="100%" bgcolor="#CCCCCC" align="right">
<input type="button" value="È· ¶¨" name="Ok">
<input type="button" value="È¡ Ïû" name="Cancel" onclick="window.close();">
</td>
</tr>
</table>
</body>
</html>
pls. help me
|
|
|
|
|
I get an error with your code in IE5.0... ;)
I delete line
document.designMode="On";
and then, it was ok.
To write code into iframe, i don't do it like you :
var sel =
myiframename.document.selection.createRange;
sel().pasteHTML(myTxtHtml);
where "myTxtHtml" does not contain head and body, but only content, because iframe has already a default body tag. (try myiframe.document.body.innerHTML to view iframe content).
I get the selection in iframe (if there is no selection, it will insert at the beginning of iframe), and then use pasteHTML function which is only for IE, but it seems that you only want your editor for IE.
|
|
|
Thanks for your reply. I am a newer for dhmtl, so could you paste your code. I can not understand your reply. My target is that a web editor pops up by pressing a showModalDialog button, and it will run ok on ie 5.0 or lator.
thanks
<Added>
when the editor popup, the user can write some formmatted text in it, like MS word.
|
|
|
Hi,
i think you can't do this in a showModalDialog. This type of popup is not like a real window.
I tried your code with a window.open and it worked on IE6 and IE5.
Why are you using a showModalDialog?
if you want to get the content of iframe in window opener, you can do it like this :
for example : window.opener.arr = myiframe.document.body.innerHTML;
I can't send my code, sorry, but i'm ready to help you.
I hope you will understand this post :)
Bye
Alice
|
|
|
Thanks you very much. Yes, I can do like that. But i want to know why the showModalDialog html editor work ok in the ie5.0, and not ok in ie5.5 or lator.
|
|
|
I really don't know it is like that...
But i have seen many things in IE who have not the same behvaior between two versions IE5, IE5.5 and IE6! And it was not because the new behavior was better!
Bye
Alice
|
|
|
document.designMode = "On" worked for IE 5.
document.body.contentEditable = "True" works in IE 5.5.
for example, try:
<html>
<head>
<SCRIPT LANGUAGE=javascript>
function window_onload() {
textEdit.document.body.contentEditable = "True"; //This line works in Internet Explorer 5.5,
// but not in Internet Explorer 5.
textEdit.document.designMode="On"; //This line works in Internet Explorer 5,
// but not in Internet Explorer 5.5.
textEdit.focus();
}
</SCRIPT>
</head>
<body onload="return window_onload()" language="javascript">
<iframe name="textEdit" id="textEdit" width="400" height="280"></iframe>
</body>
</html>
|
|
|
|
|
|
|
// |