tags:

views:

48

answers:

2
my_window.document.write(' 
  <script type="text/javascript"> 
    function redirect(linkid) { 
      opener.location.href=linkid;
      window.close();
    }
  </script>
  <h1>Hello</h1>
  <p>Thank you.If you accidentally closed our website click 
  <a href="javascript:redirect('http://google.com')"&gt;here&lt;/font&gt;&lt;/a&gt; 
  to go back to our  website</p>
'); 

This is my piece of code to close a already opened pop up window by redirecting it to google.com. I think there is some problem with matching the apostrophes ' and "... how to code with (' (" (' ') ") ')... is this correct? please help me with this.

Please help me with the necessary changes wherever required.

A: 

Please read the formatting for your code -- select it all and hit ctrl + k.

Also, I suggest you need to use a backslash infront of the single quotes within the single quotes.

Kerry
+3  A: 

Yes, you need to escape the single quotes with a backslash:

... redirect(\'http://google.com\') ...

In addition keep in mind that popping up a window like that will most likely be blocked by popup blockers... apart from being a questionable practice.

Daniel Vassallo
i was able to launch pop up window with just a message. but if i want the pop up to have a link in it, i want to redirect to some page and close the pop up window.so i decided to use javascript but it is creating problems.