[英]Insert iframe into site without using document.write
Our website uses an iframe to display a library of products we offer, and recently the iframe stopped loading in Google Chrome, because they stopped supporting document.write. 我们的网站使用iframe来显示我们提供的产品库,最近,由于iframe不再支持document.write,因此iframe停止在Google Chrome中加载。 We need a solution to show the page the same way we have been, but without using document.write.
我们需要一种解决方案以与以前相同的方式显示页面,但不使用document.write。 I am a novice, and have tried several solutions but nothing has worked.
我是新手,曾尝试过几种解决方案,但没有任何效果。
what we have: 我们有什么:
<script language="JavaScript">
<!--
var ss='<span style="font-size: small;"><b>NOTICE:</b> If you are having
trouble finding a pattern, try searching the first three letters of the
pattern name in the search bar. Also, be aware that some sheers may be
photographed with a window pane to show sheer quality.<br>If you are using
Google Chrome and have an issue viewing the library, please switch to another
browser.</span><br><br>';
var upper_limit = 500000000;
//-->
document.write(ss);
function getIP(json) {
document.write('<iframe frameborder="0" marginheight="0" width="100%"
height="700" src=" ' + 'http://client.richloomfabrics.com/cgi-bin/Wdrv01?
&PARPAR=CON&MELMEL=ALL&PTYPTY=UPH&IPAIPA=' + json.ip +
'&IPACOK=' + RandomNumber(upper_limit) + '&PGMPGM=WC033&>
</iframe>');
}
</script>
<script type="application/javascript" src="https://api.ipify.org?
format=jsonp&callback=getIP"></script>
We use a shopping cart, which is why we need the random number and IP. 我们使用购物车,这就是为什么我们需要随机数和IP。 I have tried a few solutions I've seen but don't know enough about this to properly edit.
我已经尝试了一些见过的解决方案,但对它的了解不足以进行正确的编辑。 Can anyone send me in the right direction?
谁能按正确的方向发送给我?
In a very simple case you can just use innerHTML
property of body
, something like this 在一个非常简单的情况下,您可以只使用
body
innerHTML
属性,像这样
<script language="JavaScript">
<!--
var ss='<span style="font-size: small;"><b>NOTICE:</b> If you are having
trouble finding a pattern, try searching the first three letters of the
pattern name in the search bar. Also, be aware that some sheers may be
photographed with a window pane to show sheer quality.<br>If you are using
Google Chrome and have an issue viewing the library, please switch to another
browser.</span><br><br>';
var upper_limit = 500000000;
//-->
document.body.innerHTML += ss;
function getIP(json) {
document.body.innerHTML += '<iframe frameborder="0" marginheight="0" width="100%"
height="700" src=" ' + 'http://client.richloomfabrics.com/cgi-bin/Wdrv01?
&PARPAR=CON&MELMEL=ALL&PTYPTY=UPH&IPAIPA=' + json.ip +
'&IPACOK=' + RandomNumber(upper_limit) + '&PGMPGM=WC033&>
</iframe>';
}
</script>
<script type="application/javascript" src="https://api.ipify.org?
format=jsonp&callback=getIP"></script>
You can also use appendChild 您也可以使用appendChild
var iframeElem = document.createElement('iframe');
iframeElem.src = 'https://www.google.com';
document.body.appendChild(iframeElem);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.