Site page is not shown in IFRAME issue

Hi, everybody!

Today’s post is not about SharePoint, but rather about regular Web development.

Recently writing a website showing content of the other site in IFRAMEs, I met a problem. The page of some sites were normally shown inside IFRAMEs, while the pages of some other sites weren’t – IFRAME was just empty.

But the same pages (which was not visible inside IFRAME) were absolutely normally visible if I navigated to that pages in standard way typing the URL in browser address text box. Mystery!

The first example where I observed such strange behavior was Tech Net’s Blogs.

If you don’t believe me, please create simple HTML file with the only content:

<iframe src=”http://blogs.technet.com/”     style=”width:1000px;height:700px;”>

Now try to open the file in any modern browser. The content is either empty (Firefox’s behavior) or has some warning like “To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame” (Internet Explorer and similar text with Opera).

It turned out that few years ago (if not months ago!), the browser producers added support for so-called “clickjacking protection” (see more details about it in the article “How To Fight Clickjacking (Using The Recent Twitter Hijacking As An Example)“). In few words – now browsers recognize “X-FRAME-OPTIONS” response header (with two possible values), and presence of this header in the response means that the page SHOULD NOT be shown in IFRAME.

So I needed somehow to ask the browser to ignore this response header. Unfortunately Firefox doesn’t have any option for it. So I had either to use some intermediary proxy like WebScarab, or to use Fiddler 2 asking it to remove undesired header.

I used the last one. There is documentation how to remove header from response stream in Fiddler 2. It worked like a charm.

UPDATE: Please notice, this approach works only on client side – so it is not possible to make a widely accessible site showing an arbitrary site in IFRAME if the latest site forbids showing itself in IFRAME using X-FRAME-OPTIONS.

In my case it worked, because I was the only user of my site.

Hope it helps!

Advertisement

About vtimashkov

.NET, ASP.NET, SharePoint/MOSS developer
This entry was posted in Ideas for projects. Bookmark the permalink.

6 Responses to Site page is not shown in IFRAME issue

  1. What’s the value of removing the header locally?
    Users still will be unable to see the site on iframe.

    • vtimashkov says:

      I am the only user of my site – it is internal tool for local purposes.
      And you are right – I will add proper text in the post …

  2. baggersrusgrizzly says:

    just use Google Chrome

    also use this ‘embed’ syntax is an example menu link http://www.youtube.com/embed/CNGTn3eismo

    cheers

    • vtimashkov says:

      No, it doesn’t work – neither using of the latest Google Chrome, nor ‘embed’ syntax.
      Have you checked yours ideas?

      • grizzly says:

        I sure have – I was pulling my hair out – I am using wordpress.com the free online blog and my select authors kept getting the error so I told them to switch to Chrome and I also added /embed/ to my links and hewh presto – PERFECT..

      • vtimashkov says:

        Yeah, I understand – thanks for advice!
        Unfortunately, these things didn’t help :-(

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s