2016-09-23 29 views
1

我对IFrame的知识有限。到目前为止,我知道一个IFrame的“src”应该有一个从哪里获取内容的URL。但是最近,我看到很多的IFrame其内容如下:在src中没有正确的URL的iframe

<iframe id="google_ads_iframe_/20346936/skysports/homepage_0" title="3rd party ad content" name="google_ads_iframe_/20346936/skysports/homepage_0" width="728" height="90" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" src="javascript:&quot;<html><body style='background:transparent'></body></html>&quot;" style="border: 0px; vertical-align: bottom; height: 90px;"></iframe> 

现在如果我们查看到“src”属性的

src="javascript:&quot;<html><body style='background:transparent'></body></html>&quot;" 

那么这是什么意思,以及如何是多少I帧人口。任何知识或指针将不胜感激。

非常感谢。

回答

2

它将内容注入iframe。

有关于好文章:

简单的例子:

HTML


<div class="main"> 
    <iframe id="iframe1"> 
    </iframe> 
</div> 

CSS


#iframe1 { 
    border: solid 1px; 
    border-radius: 8px; 
    width: 80%; 
    min-height: 80%; 
    max-height: 80%; 
    color: red; 
    padding-top: 1em; 
    margin: 0 auto; 
} 

JS


$('#iframe1').contents().find('html').html("<h1 style='text-align: center;'>This IS an iframe</h1>"); 

结果


enter image description here