【发布时间】:2018-03-21 23:29:01
【问题描述】:
我们的网站使用 iframe 来显示我们提供的产品库,最近 iframe 停止在 Google Chrome 中加载,因为它们停止支持 document.write。我们需要一个解决方案来以与我们一样的方式显示页面,但不使用 document.write。我是新手,尝试了几种解决方案,但都没有奏效。
我们拥有的:
<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>
我们使用购物车,这就是为什么我们需要随机数和 IP。我已经尝试了一些我见过的解决方案,但对此知之甚少,无法正确编辑。任何人都可以向我发送正确的方向吗?
【问题讨论】:
-
这部分是否在某个 HTML 元素中?如果它是带有
id="documentWriteElement"的元素,您可以将document.write替换为document.getElementById("documentWriteElement").innerHTML。 -
但是我建议您查看
document.createElement和element.appendChild而不是innerHTML。
标签: javascript html google-chrome iframe document.write