sahista said:
Hello.
I create an iframe on the fly, set it to editable designMode='on' and
insert into iframe.contentWindow.childNodes[0].childNodes[1] some
innerHTML.
Ok... that all works fine in IE but in firefox it wont became editable
neither insert the innerHTML!?
Well I for one am intrigued. What's this designmode and setting an
iframe to editable all about? I've never needed to set anything to be
editable to write to innerHTML. I expect I'm about to learn something
here
ok...
this is the code
HTML:
<html>
<head>
<script type="text/javascript" language="javascript">
window.onload = function() {
var iFrm =
document.createElement("IFRAME"), aIF;
with(iFrm) {
scrolling = "yes";
frameborder = 0;
width = 300;
height = 200;
}
document.getElementsByTagName("BODY")[0].appendChild(iFrm);
aIF = iFrm.contentWindow.document
|| iFrm.contentDocument.document;
aIF.onreadystatechange =
setEditable;
}
function setEditable() {
if(this.readyState == "complete") {
this.designMode =
"on";;
}
}
</script>
</head>
<body>
</body>
</html>
this works in IE but not in firefox!
in firefox the onreadystatechange property is ignored!!??
and the question is how to insert some HTML code into the iframe
document after it became editable..
any suggestion appreciated..
thanx in advance
solved on window.setTimeout but its not that object oriented that i
wanted with onreadystatechange but it seems firefox doesnt understand
it when the property is used on iframe...
hth
<html>
<head>
<script type="text/javascript" language="javascript">
window.onload = function() {
var iFrm =
document.createElement("IFRAME"), aIF;
with(iFrm) {
scrolling = "yes";
frameborder = 0;
width = 300;
height = 200;
id = "edit_ifr";
}
document.getElementsByTagName("BODY")[0].appendChild(iFrm);
window.setTimeout("setEditable('"
+ iFrm.id + "')", 100);
}
function setEditable() {
var iFrDoc =
document.getElementById(arguments[0]).contentWindow.document ||
document.getElementById(arguments[0]).contentDocument.document;
if(!document.all) {
iFrDoc.body.innerHTML
= "testiram";
iFrDoc.designMode =
"on";
} else {
iFrDoc.body.innerHTML =
"testiram";
iFrDoc.body.contentEditable =
true;
}
}
</script>
</head>
<body>
</body>
</html>