Opened Window:
window.opener.variable = document.getElementById(target).value; //string
window.opener.focus();
Window Opener
alert(variable);
Could this be done? The above example doesn’t work.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This can be done, but not across different domains.
If you want to cause the original window to alert the variable:
Testcase:
Type
javascript:void window.open("http://stackoverflow.com/");in this window. A new window will open.Type
javascript:void window.opener.alert(location.href);in the location bar of the new window, and press Enter. The original window will show an alert box.I have successfully executed this in FireFox 3.6.22 and the newest version of Chromium.
When I open “http://www.example.com/” instead of “http://stackoverflow.com/”, a JavaScript error will occur, caused by the same-origin policy.