Saurabh Saxena
Saurabh Saxena

Reputation: 3205

Trying to open a URL in iframe

I have two iframes in a HTML page with 50% of the screen shared by both.

In the first iframe http://www.google.com is opened and in the second iframe http://www.nytimes.com is opened.

On Page Load, the page is automatically redirecting to http://www.nytimes.com.

What could be the problem for this?

Upvotes: 0

Views: 870

Answers (5)

Saurabh Saxena
Saurabh Saxena

Reputation: 3205

Check this out OWASP - ClickJacking

Only for Chrome

<iframe id="my_frame" sandbox> </iframe>

Works great for me ... :)

Upvotes: 0

Shadow Wizard
Shadow Wizard

Reputation: 66389

Their home page include this JS file which contains the following code:

(function() {
    if (window.self != window.top && !document.referrer.match(/^https?:\/\/[^?\/]+\.nytimes\.com\//)) {
        var expTime = new Date();
        expTime.setTime(expTime.getTime() + 60000);
        document.cookie = "FramesetReferrer=" + document.referrer + "; expires=" + expTime.toGMTString() + "; path=/";
        top.location.replace(window.location.pathname);
    }
})();

This cause the behavior you see.

To protect against this, see the following question here: Keeping pages inside an iframe

Upvotes: 2

Josep Valls
Josep Valls

Reputation: 5560

i am guessing that you mean that the iframe container is being redirected. maybe you want to check for some sort of iframe inclusion detection. take a look at: From the server is there a way to know that my page is being loaded in an Iframe

Upvotes: 0

Jan Dragsbaek
Jan Dragsbaek

Reputation: 8101

Simply because nytimes.com dislike frames and wants to use all of your browserspace.

Why would you ever make a site like that anyway?

Upvotes: 0

symcbean
symcbean

Reputation: 48357

Most likely, the nytimes.com home page has framebuster script on it.

Upvotes: 4

Related Questions