1
我有以下代碼的主要頁面加載異步I幀不工作
<head>
<title></title>
</head>
<body>
<script>
(function(d){
var iframe = d.body.appendChild(d.createElement('iframe')),
doc = iframe.contentWindow.document;
// style the iframe with some CSS
iframe.style.cssText = "position:absolute;width:200px;height:100px;left:0px;";
doc.open().write('<body onload="' +
'var d = document;d.getElementsByTagName(\'body\')[0].' +
'appendChild(d.createElement(\'script\')).src' +
'=\'http:\/\/google.com\'">');
doc.close();
})(document);
</script>
</body>
不幸的是後加載iframe中的內容,該代碼並不如預期的工作。任何人都可以指出這裏有什麼問題嗎?
謝謝!
當我將google.com更改爲'mydomain.com','mydomain.com'也沒有加載,但奇怪的是我在我的cPanel – aye
@aye的統計數據中,仍然會從我的IP中獲得成功。原因可能是跨域訪問。如果您的頁面位於本地主機上,請嘗試將iframe設置爲本地頁面 – VladL
我試着將其更改爲相同的域,但仍無法使用。在所有情況下,我看到加載的iframe,但iframe中的內容未顯示 – aye