我們的網站使用iframe來顯示我們提供的產品庫,最近iframe停止在Google Chrome中加載,因爲它們停止支持document.write。我們需要一種解決方案,以與我們一樣的方式顯示頁面,但不使用document.write。我是一個新手,並嘗試了幾種解決方案,但沒有任何工作。將iframe插入站點而不使用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.getElementById(「documentWriteElement」)。innerHTML'替換document.write。 – Walk
但是,我建議你看看'document.createElement'和'element.appendChild'而不是'innerHTML'。 – Walk