简体   繁体   中英

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,

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM