How to do a redirect in parent window using an iframe

Sometimes you may be required to make the user visit a particular url from webpage which is loaded in an iframe into another website/webpage

E.g if www.example.com has an iframe which loads your page and you can redirect the entire iframe along with parent window to a new page by making use of the new script

So here is the code which you can place inside the iframe to redirect the parent


window.top.location.href = "http://www.example.com"; 

(or)

window.top.parent.href = "http://www.example.com";

You can use either one of these

Scroll to Top