我在一个页面里放了一个iframe,我想在页面载入之后,往iframe中输入的字就是斜体的。 部分代码如下:
<html>
<head>
</head>
<body>
<iframe id="frame1" name="frame1"  >
</iframe>
<script type="text/javascript">
var iframeTemp = document.getElementById("frame1");
var editorDocument = iframeTemp.contentWindow.document;
editorDocument.designMode = "on";
window.onload=function()
{
frame1.focus();
editorDocument.execCommand("Italic",false,null);
}
</script>
</body>
</html>我发现了一个很奇怪的问题: 1 frame1.focus()一定要放在onload函数里才有效果。 2  editorDocument.designMode = "on"; 与 frame1.focus(); 不能放在一起,否则会导致无法获得焦点。   搞了很长时间无法明白,谁能帮我解答一下这两个问题,谢谢!!