取父窗口的元素方法:
$(selector, window.parent.document)
那么你取父窗口的父窗口的元素就可以用:
$(selector, window.parent.parent.document)
类似的,取其它窗口的方法大同小异,
$(selector, window.top.document)
$(selector, window.opener.document)
$(selector, window.top.frames[0].document)
js:
父窗口:
1、<input type="text" name="currentProjectIDForDetail" id="currentProjectIDForDetail"
disabled
2、<input type="button"
onclick="window.open('showDetails.html','','toolsbar=no,menubar=no,resizable=yes,scrollb
ars=yes')" value="查看已有明细" id="showDetail" />
子窗口:
curproject = window.opener.document.getElementById("currentProjectIDForDetail").value
jQuery:
父窗口:
<input type="text" name="aa" id="aa" />
<input type="button"
onclick="window.open('son.html','','toolsbar=no,menubar=no,resizable=yes,scrollbars=yes')
" value="send" />
子窗口:
<script>
$(function () {
temp=$("#aa",window.opener.document).val()
$("#bb").html(temp)
})
</script>
</head>
<body>
<div id="bb"></div>
发现答非所问的人还不少啊取父窗口的元素方法:$(selector, window.parent.document)
那么你取父窗口的父窗口的元素就可以用:$(selector, window.parent.parent.document)
类似的,取其它窗口的方法大同小异
$(selector, window.top.document)
$(selector, window.opener.document)
$(selector, window.top.frames[0].document)
希望对你能有帮助
$(function(){//相当天body的 onload,要等页页面加载完毕后才能找到iframe$("#hong").contents().find("body").append("I'm in an iframe!")
})
</script>
<iframe width="1198" height="729" name="hong" id="hong" src="" scrolling="no" style="text-align:center"></iframe>