javascript - How do I redirect the window that opened a popup window to a new page by clicking a button in the popup window? -


i have page opens popup window , in popup window, have link should redirect window opened current window page called privacy.html.

i know i'm supposed use window.opener refer window , found other question solution use setinterval. might useful this.

how focus on opened window using window.open()

anyways code , doesn't work redirect opener window can see i'm trying do.

<script type="text/javascript">   function validateemail() {     var emailrule =  /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/;      if (emailrule.test(document.forms[0].email.value)) {          document.getelementbyid("body").innerhtml = "thank signing our newsletter! recieve confirmation email shortly.";          settimeout("window.close()", 3000);     }     else {          document.getelementbyid("message").innerhtml = "please enter valid email address";     } }  function privacywindow() {      window.opener("privacy.html"); } </script>  </head> <body id="body"> <p>if sign our newsletter entered drawing win free clothes every month!</p> <p id="message"><br></p> <form action="" onsubmit="validateemail();"> <p>email: <input type="text" name="email"/> <input type="button" value="sign up" onclick="validateemail();"/></p> <br> <input type="button" value="no thanks" onclick="window.close()"/> <br> </form> <p><a href="" onclick="privacywindow();">privacy policy</a></p> </body> </html> 

change:

window.opener("privacy.html"); 

to:

window.opener.location.href = "privacy.html"; 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -