I know on the same page frame or parent I can make either go to something via window.location
however is there a means of checking to see if I am in the iframe and if so make the top (parent window) location go somewhere?
1 Expert Answer To force a single link from iframe to open in the parent window: add target="_PARENT" within that links anchor tag. To force ALL links from iframe to open in the parent window: add the base tag with target="_PARENT" in the head section of the iframe html page.
You can still access parent from within an iframe even though you can't access anything useful on it. This code will never cause an error even when crossing origins.
This is a simple code to check if your page is loaded in iframe:
if (window.location != window.parent.location)
window.parent.location = "http://someurl";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With