<script>
for(i=0;i<window.frames.length;i++)window.open(window.frames[i].location)
</script>
跨域了,可以:
document.getElementsByTagName("IFRAME")
这样也是返回一个数组,然后再引用它的location
document.getElementsByTagName("IFRAME")[i].document.location.href
用frame的时候一般是parent.frames[i]
而iframe是在frame里面的window.frames[i]就是iframe
如何获取<iframe>里的form值
form.htm的html代码如下
<html>
<head>
<title>demo</title>
</head>
<body>
<form id='form' name='form' method='post' action='act.php'>
name:<input id='username' name='username' type='text' />
<input type='submit' value='submit' />
</form>
</body>
</html>
demo.html代码如下
<html>
<head>
<title>demo</title>
</head>
<body>
<iframe id='target' name="form" src='form.htm'></iframe>
<input type=button onclick="alert(frames['form'].document.forms[0].username.value)" value="display username">
</body>
</html>