javascript - window.opener doesn't work in firefox and chrome but in IE -
i have problem window.opener function (js):
i created 3 simple pages simulate problem:
test.php:
<html> <head> </head> <body> <input type="button" onclick="window.open('first_page_in_popup.php', 'popup', 'width=470,height=500');"> <input type="text" id="content" name="content" > </body> </html>
first_page_in_popup.php:
<html> <head> <script type="text/javascript" > window.opener.document.getelementbyid('content').value= "test first page in popup"; window.open('second_page_in_popup.php', 'popup'); </script> </head> <body> </body> </html>
second_page_in_popup.php:
<html> <head> <script type="text/javascript" > window.opener.document.getelementbyid('content').value= "test second page in popup"; </script> </head> <body> </body> </html>
result: in ie, input field has content "test second page in popup". in chrome , firefox, content : "test first page in popup".
the error message:
window.opener.document.getelementbyid(...) null
i solved problem changing code of page "first_page_in_popup.php" to:
<html> <head> <script type="text/javascript" > window.opener.document.getelementbyid('content').value= "test first page in popup"; window.location.href = 'second_page_in_popup.php'; </script> </head> <body> <p> first page </p> <input type="text" id="first" name="first"> </body> </html>
Comments
Post a Comment