读书人

小弟我的iframe里面有一个div小弟我

发布时间: 2012-08-01 17:53:40 作者: rapoo

我的iframe里面有一个div,我怎么让这个页面打开的时候鼠标的焦点在div里面呢?
在页面里套用了一个iframe,然后动态给iframe添加了一个div,给设置为可编辑状态,怎么能让程序运行的时候鼠标的焦点就在这个div中?

还有一个问题是如果我运行页面,然后全选删除,那么那个div也跟着删掉了 ,有什么方法可以保留这个div么?

[解决办法]
动态添加的div的id为div1:
document.getElementById("iframe1").contentWindow.document.getElementById("div1").focus();
[解决办法]
这样:

JScript code
    <script type="text/javascript">        window.onload = function() {            document.getElementById("showValue").contentWindow.document.write("<html><body style='margin:0px'><div id='showMSG'  style='border:solid 1px #ccc;' ></div></body></html>");            //document.getElementById("showValue").contentWindow.document.getElementById("showMSG").innerHTML="aaaa";            document.getElementById("showValue").contentWindow.document.getElementById("showMSG").contentEditable = "true";            document.getElementById("showValue").contentWindow.document.getElementById("showMSG").focus();            //document.getElementById("showValue").contentWindow.document.designMode = "on";        }    </script> 

读书人网 >C#

热点推荐