试试用 插入 HTML 代码的方式吧.这个应该是IE的BUG
你用 document.body.innerHTML +='<iFrame id="test" name="test" src=""></iFrame>';
准保就好了.
你用 document.body.innerHTML +='<iFrame id="test" name="test" src=""></iFrame>';
准保就好了.
解决方案 »
- 征求masonry框架学习
- js简单问题
- 请问:每个页面的顶部都是一样的,如何才能改一个地方就可以修改所有页面相同的顶部
- 还有个问题请教..想求H列的和.谢谢.
- javascript智能提示工具
- 像这种代码,能否通过变量使JavaScript更加简练?
- FOR循环赋值时,赋值却始终只能给最后一个控件,请高手帮忙解决
- 我的javascript代码怎么不起作用啊?请高人指点。
- 在JSP的页面中用JAVASCRIPT写的window.close()事件,在关闭窗口时怎么不出提示就直接关闭窗口呢?
- 一个小问题:如何最大化?(急!急!)
- 删除选中的多行?
- 框架中有好几个页面组成,父窗体如何把获取到的参数传递给各个子框架内的页面?
以下代码演示ie的情况:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> new document </title>
<meta name="generator" content="Microsoft FrontPage 4.0">
<script language="JavaScript">
<!--
window.onload = function(){
var iframe = document.createElement('iframe');
iframe.name="aaa";
alert(iframe.outerHTML);
document.body.appendChild(iframe);
document.frames[0].name="test";
}
//-->
</script>
</head><body>
<form action="test.asp" target="test" onsubmit="alert(document.getElementsByName('test').length);">
<input type="submit" value="do"/>
</form>
</body>
</html>
另外,ie也可以通过如下来create带名字的标签:
var iframe = document.createElement('<iframe name="test">');
document.frames[0].name="test";//赋值成功原因并不是“对于ie,iframe标签的name是readonly的”
因为IE中是这样说明的:name
--------------------------------------------------------------------------------Description
Specifies the name of a window or the frame so it can be targeted from links in other documents. Syntax
object.name[ = sName] //以这种语法表示的是可读写的属性。Settings
This read/write property takes either a window name or frame name, or one of these special valuesRes
An exception to the rule, the window keyword must be used to access the name property.
An exception to the rule, the window keyword must be used to access the name property.
意思就是必须通过window关键字(也就是window对象)来访问window/frame的name属性。
尽管在某些用途上,二者有互通的情况,
但是它们不是一样的,
IE的帮助文件里对这一点有些含糊。示例代码里,每次点do,alert出来的都是0,
可见,<iframe>的name并没有改变,是只iframe里window的name有了改变.
--->>>
一个是window对象的name,一个是iframe标签的name,