Please help I have develop two web pages.I want to check for open the child windo开发者_JAVA百科w. that come from parent window or direcltly copy paste the url of the page in javascript.
window.opener
should contain something(a window-object) if an window is a child-window of another(opened using window.open() ) .
So you have to check window.opener
to see if a window is a child-window.
Assuming you have Page1.html and Page2.html, Page2.html can know if it was opened from within Page1.html by two ways:
<script type="text/javascript">
if (typeof window.opener != "undefined")
alert("I was opened from within " + window.opener.location.href);
else if (document.referrer)
alert("You came here from " + document.referrer);
</script>
精彩评论