我使用designMode=on创建iframe。
当我在IE中打开网站并在iframe上移动鼠标光标时,鼠标光标变成了文本光标(大写字母I)。
但当我在Firefox中打开网站时,关联并没有改变,仍然是箭头光标。
如何解决这个问题?
<script language="javascript" type="text/javascript">
designer('content');
function designer(editor) {
var browser = navigator.userAgent.toLowerCase();
isIE = (browser.indexOf("msie") != -1);
document.writeln('<iframe id="' + editor + '" width="600px" height="600px"></iframe>');
var edit = document.getElementById(editor).contentWindow.document;
edit.designMode = "On";
if (!isIE) {
document.getElementById(content).contentDocument.designMode = "on";
}
}
</script>发布于 2009-11-05 00:48:06
也许this page能帮上忙?
发布于 2009-11-06 10:46:02
你的台词是:
if (!isIE) {
document.getElementById(content).contentDocument.designMode = "on";
}几乎可以肯定的是:
if (!isIE) {
document.getElementById(editor).contentWindow.document = "on";
}实际上,您是在请求非IE浏览器查找id为null的元素,而不是id为'content'的元素。
然而,这不会在您的IFrame中得到一个文本插入符号,即使它确实使其可编辑。
我能想到的最好的结果是:
document.getElementById(editor).contentWindow.document.style.cursor = "text";这会在的第一行(即顶部)将光标转换为一个插入符号iFrame,大概是因为这是该点上唯一可编辑的部分。
发布于 2011-07-25 07:53:59
必须在iframe loads时设置此属性。
var edit = document.getElementById(editor).contentWindow.document;
edit.addEventListener("load", function() {
edit.designMode = "On";
}, false);https://stackoverflow.com/questions/1674990
复制相似问题