我有兩個HTML頁面一個是parent.htm
等是child.html
在那裏我有在parent.htm' to
child.html , here i have to access the elements of
parent.htm in
child.html`給出href
,這裏有我的兩個文件如何使用java腳本訪問其他HTML表單中的一個HTML表單元素?
parent.htm
<!DOCTYPE html>
<html>
<body>
<form>
<input id=text1 type=text name="test2">
<a href="child.html" target="_self">Open kid</a>
</form>
</body>
</html>
child.html
<html>
<script type="text/javascript">
function parent(){
//here i want to access values from parent.htm page, but does not work
var value = parent.getElementById('text1').value;
var value2=top.getElementById('text1').value;
alert(value);
}
</script>
<body onload="parent()">
<form>
</form>
</body>
</html>
在此先感謝
檢查這可能會幫助你http://stackoverflow.com/questions/13151634/callback-function-call-when-child-window-is-close – Hkachhia
任何原因,你不能只是在客戶端上設置cookie和在第二頁閱讀它們? – Tim
的要求是隻使用JS @Tim – MaheshVarma