2013-07-22 119 views
8

我的想法是更新iframe中主页中文本框的值。此代码在firefox中工作,但不在Internet ExplorerChrome中工作。 main.htmlframe.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> 
+0

在控制台中的任何错误? – Cherniv

+0

你试过'window.top.document' –

+0

尽管你应该真的关闭你的