Check if a page is loaded in an iframe

Posted by 6bytes at 30, June, 2011

Category: JavaScript

Tags: , ,

Just a quick tip, how to check if current page has been loaded in an iframe or was it accessed directly.

if (window.self === {
    // we're NOT in an iframe
} else {
    // we're in an iframe

That’s it.

  • Rob

    Loving your quick tips. More please.


  • You can definitely see your enthusiasm in the article you write.
    The sector hopes for more passionate writers like you who aren’t afraid to say how they believe. At all times follow your heart.

  • Ootko blogannu kauankin?

  • Your current article provides established necessary
    to us. It’s extremely useful and you are certainly very educated in this region.
    You possess opened my eyes for you to varying opinion of this kind
    of subject using intriquing, notable and reliable content material.

  • Your article offers established useful to myself.
    It’s quite informative and you’re certainly quite knowledgeable in this area. You get opened up my personal face for you to numerous thoughts about this kind of topic with intriquing, notable and solid content.

  • I visited several web sites however the audio feature for
    audio songs present at this website is genuinely superb.

  • Hey there would you mind sharing which blog platform
    you’re working with? I’m planning to start my own blog in the near future but I’m having a tough time selecting between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different then most
    blogs and I’m looking for something unique. P.S Sorry for getting off-topic but I had to

  • luki

    bla bla bla, fajne fajne 🙂

    Przydało mi sie 😀 do zrobienia najgłupszego wylogowywania ever.

    • No i bardzo dobrze, właśnie o to chodziło, żeby się przydało 🙂

  • Greetings, I believe your blog might be having browser compatibility problems.

    Whenever I look at your website in Safari, it looks
    fine however, if opening in IE, it has some overlapping issues.
    I just wanted to provide you with a quick heads up!
    Besides that, fantastic website!

  • After exploring a handful of the blog articles on your website, I seriously like
    your technique of writing a blog. I book marked it to my bookmark webpage list and will be checking back in the near future.
    Take a look at my website too and tell me your opinion.