How can i understand that my page is being called from iframe and break it with jquery ? Thank you.
Redirect the page containing your iframe embed Modern browsers will prevent an iframe from changing the location of its parent page for security reasons. Your iframe embed code and JavaScript code will need to be modified to allow this behavior.
Use sandbox attribute. <iframe src=”Site_URL” sandbox=””> – Full Protection. <iframe src=”Site_URL” sandbox=”allow-forms allow-scripts”> – Allow form submission and scripts to run.
allow-top-navigation allows the document to break out of the frame by navigating the top-level window.
if (self !== top)
top.location.replace(self.location.href)
that's how you break out of a frame
This can be done in plain Javascript since top
and location
are both objects attached to the global window
object provided in all major browsers.
if (top.location != location){
location.href = 'http://google.com';
}
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