0
我正在实现构建页面编辑器。有一个问题让我疯狂在Firefox中。为什么弹出警报会影响“designMode”?
页面代码如下:
<body>
<iframe WIDTH=200 HEIGHT=200 id="myEditor"></iframe>
<script>
function getIFrameDocument(sID){
// if contentDocument exists, W3C compliant (Mozilla)
if (document.getElementById(sID).contentDocument){
alert("mozilla"); // comment out this line and it doesn't work
return document.getElementById(sID).contentDocument;
} else {
// IE
alert("IE");
//return document.getElementById(sID);
return document.frames[sID].document;
}
}
getIFrameDocument("myEditor").designMode = "On";
</script>
</body>
它只是检查是否approprate设置在Mozilla的方式或IE的方式“的designMode”。当页面加载时,会弹出一个“Mozilla”;点击iframe区域,焦点在iframe上,我可以用键盘输入。
这看起来不错,但是当我注释掉行“alert(”mozilla“);“,它不工作。 FireBug显示的“designMode”为“Off”。
这是如此有线。为什么警报会影响DOM和JavaScript? 顺便说一句,我的Firefox是3.0.6。
谢谢。该修复使其工作! “designMode可以在iframe加载后”仅适用于Firefox,对不对?看来IE并没有这样的限制。 – 2009-04-12 06:16:20