Search code examples
javascriptiframehref

How to open link from iframe using javascript


I have this:

<td onclick="window.location='http://www.google.com/';"> </td>

The problem is that I have this inside an iframe, so onclick it opens in the iframe. How do I open this link on the parent page instead of the iframe?

(Is there a way to do this with one js script for all the links on the page?)


Solution

  • window.parent.location.href='http://www.google.com/';
    

    and if you want to reload the top most window:

    window.top.location.href='http://www.google.com/';