If I have a script which calls window.open, loading a new page into the same window, then that new page's JavaScript needs to identify the Previous Page's URL - what is the best way to find it?
3 Answers
You can use window.opener to obtain a reference to the window that opened the current window. Not sure if this is what you are after. When using window.open it will result in a new window, not sure what you mean by "open new window in the same screen".
2 Comments
jimmy.sunny
we can open new screen in the same window like window.open("About.html", '_self'). And in the new screen i want the previous page url.
CyberDude
Can you pass a parameter to the new page?
Using Window.opener you can get it, like
var win=window.open('http://heera.it');
console.log(win.opener.location.href); // will output the url
Example.
1 Comment
jimmy.sunny
Actually i want to open new screen in the same window itself by using window.open("About.html", '_self'). so after this when i use window.opener.location.href is not giving any value