user1865619
user1865619

Reputation:

Hide DIV within Iframe

Is it possible to hide a DIV within an Iframe if the source is some website not on your domain? I have an iframe that loads a site but want to hide a specific div.

EX: Hide DIV id = slider src = www.somesitecom.com

What I have tried without success; Is is because a cross site scripting is not allowed?

$(function(){
        var f=$('#foo')
        f.load(function(){ 
            f.contents().find('#slider').hide(); 
        })
    })

<iframe id="foo" src="http://somesite.com" style="width:1200px; height:800; border:none; margin-left:-60px;"/></iframe>

Thanks,

Upvotes: 3

Views: 1613

Answers (2)

Gary Hayes
Gary Hayes

Reputation: 1788

Yeah. If you could manipulate other peoples pages so easily, you'd be able to access their databases or make phishing sites even easier.

You could make a solid colored div and overlay it with z-index to hide whatever is offending you, though.

Upvotes: 0

letiagoalves
letiagoalves

Reputation: 11302

Browsers do not allow iframe manipulations outside your domain for security reasons since you could get user confidential information in that page. For example, if that iframe is currently on a "Change profile" page, you could get really dangerous information.

Upvotes: 2

Related Questions