1、window.parent 是iframe页面调用父页面对象
举例: a.html
<html>
<head><title>A</title></head>
<body>
<form name=”form1″ id=”form1″>
<input type=”text” name=”username” id=”username”/>
</form>
<iframe src=”b.html” width=100%></iframe>
</body>
</html>
如果我们需要在b.html中要对a.html中的username文本框赋值(就如很多上传功能,上传功能页在ifrmae中,上传成功后把上传后的路径放入父页面的文本框中),我们应该在b.html中写:
<script type=”text/javascript”>
var _parentWin = window.parent;
_parentWin.form1.username.value = “xxxx”;
</script>
近期评论