请高手帮我解决一下客户端的javascript问题
myljg 2008-02-28 12:20:49 我想写个基.net的在线HTML编辑系统,
在写客户端的脚本代码时出个问题,代码如下:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>
无标题页
</title>
</head>
<body>
<form name="form1" method="post" action="" id="form1">
<div>
<input id="test" name="test" type="hidden" value="abcdefg">
<iframe name="EF_test" id="EF_test" onblur="EF_ViewValueChanged()" style="width:500px; height:250px;"> </iframe>
<script type="text/javascript">
var EF_HiddenValue=document.getElementById("test");
var EF_ViewValue=document.getElementById("EF_test");
EF_ViewValue.document.open();
EF_ViewValue.document.write(EF_HiddenValue.value);
EF_ViewValue.document.close();
EF_ViewValue.document.designMode="On";
function EF_ViewValueChanged(){
EF_HiddenValue.value=EF_ViewValue.document.body.innerHTML;
}
</script>
<br>
<input id="Button2" onclick="alert(test.value);" type="button" value="button" />
</div>
</form>
</body>
</html>
我想要的结果是
一打开网页是,将隐藏字段中的value值写放iframe中,
并且通过designMode方法开启iframe的设计方法,
由于特殊需要,不能直接引用iframe的ID,我便用getElementById方法获取对iframe的引用
可是发现这样引用的结果不对,
这样引用的是当前页,页不是iframe
请那位高手能帮忙解决一下?