简体   繁体   English

删除iFrame的html标签样式

[英]Remove style of html tag of iFrame

I've got a iFrame on my page which is coming in from an external source and when the iFrame is loaded it's coming in with it's 'own' styling classes and I'm trying to remove one of the classes what it has. 我的页面上有一个iFrame,它是从外部来源传入的,加载iFrame时,它是带有“自己的”样式类的,因此我试图删除其中一个类。 So when the iFrame loads the HTML looks like this: 因此,当iFrame加载HTML时,它如下所示:

<iframe style="background-color:#fff !important" id="myFrame" src="http://salonspy.co.uk/widget?i=72108" frameborder="0" height="270" width="320">
#document
    <html> <!---THIS IS THE TAG I'M TRYING TO GET A HANDLE ON!-->
        <head>...</body>
        <body>...</body>
    </html>
</iframe>

The html tag has a background color applied to it (by the external css) and I'm trying to remove this background-color (or apply a transparent one) but I can't seem to get 'hold' of this tag. html标记具有(通过外部CSS)应用的背景颜色,而我正在尝试删除此背景颜色(或应用透明的背景颜色),但我似乎无法“保留”该标记。

I've got some jQuery that waiting for the iFrame to load but I don't know what to enter to apply this new style. 我有一些等待iFrame加载的jQuery,但我不知道要输入什么才能应用这种新样式。

$(function() {
$("#myFrame").bind("load",function(){
    //$(this).contents().find("[tokenid=" + token + "]").html();
    alert("iFrame loaded");
    //$(this).contents().find("html").css("background-color","white");
    var src = $('#myFrame>html').html();
    alert(src);
});
});

Could someone assist please? 有人可以帮忙吗?

Thanks. 谢谢。

Moving from comment to answer. 从评论到答案。

If you are accessing salonspy.co.uk from within the same origin , you may access the HTML contents by calling the inner HTML: 如果您从同一来源访问salonspy.co.uk,则可以通过调用内部HTML来访问HTML内容:

Plain JavaScript 纯JavaScript

document.getElementById('myFrame').contentWindow.document.bo‌​dy.innerHTML

jQuery jQuery的

$('#myFrame').contents().find("html").html();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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