我的想法是更新iframe中主页中文本框的值。此代码在firefox
中工作,但不在Internet Explorer
和Chrome
中工作。 main.html
和frame.html
都位于相同位置。我需要建议使其在所有浏览器中都能正常工作。window.parent.document在Firefox中工作,但不在Chrome和IE中
main.html中
<!DOCTYPE html>
<html>
<head>
<title> main window </title>
</head>
<body>
Parent textbox :<input type="text" id="parentbox"></br></br></br>
<iframe src="frame.html" ></iframe>
</body>
</html>
frame.html
<!DOCTYPE html>
<html>
<head>
<title> frame window </title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
function PushValues()
{
var frame_value = document.getElementById("framebox").value;
window.parent.document.getElementById("parentbox").value =frame_value;
}
</script>
</head>
<body>
<input type="text" id="framebox" >
<input type="button" value ="fill" onclick="PushValues()">
</body>
</html>
在控制台中的任何错误? – Cherniv
你试过'window.top.document' –
尽管你应该真的关闭你的