Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you check if your document is opened in an IFrame?

Is there a way to know if your page is opened inside of an IFrame?

An idea I had was to see if the window object has a .parent property, but this apparently is also true of standalone windows which are opened by Javascript's window.open() function.

like image 697
levik Avatar asked Oct 12 '10 20:10

levik


People also ask

How do I know if my iframe is working?

Comparing the object's location with the window object's parent location: Here, we simply compare the object's location with the window object's parent location. If the result is true, then the webpage is in an iFrame. If it is false, then it is not in an iFrame.


Video Answer


1 Answers

if (window.top != window.self)
 {
}
like image 75
John Hartsock Avatar answered Oct 13 '22 00:10

John Hartsock