Search code examples
htmliframehref

How do I make This Open Automatically and not need to be pressed?


I have a website running inside an iframe but when links are selected they run within the iframe which keeps the url the same.

I have found a piece of code that when it is pressed, it takes you to the website outside of the iframe, however for my purposes it needs to be automatic.

The entitire Pages code is:

<!DOCTYPE html>
<html>

<a target="_parent" href="http://www.MyWebsite/Contact_Us.com">Click Here</a>

</html>

This works but I don't want the user to have to press it. Is there any simple way of making this run automatically upon the page being opened?

Thanks in advance


Solution

  • This works for me. Put this in the page loaded into your iframe.

    <body onload="parent.location='http://www.MyWebsite/Contact_Us.com'">