JavaScript
Article
By Sam Deering

jQuery Check if Window is in iFrame

By Sam Deering
Help us help you! You'll get a... FREE 6-Month Subscription to SitePoint Premium Plus you'll go in the draw to WIN a new Macbook SitePoint 2017 Survey Yes, let's Do this It only takes 5 min

Simple JavaScript code snippet to check whether or not a window is in an iFrame. Very useful for some functions that may make use of the URL in the address bar of the page.

Simple as this.

var isInIframe = (window.location != window.parent.location) ? true : false;

Also See:

--ADVERTISEMENT--

Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.Is it good?