【发布时间】:2014-08-30 06:52:35
【问题描述】:
我从另一个来源获得此代码,以便在我的网站上使用,
<!DOCTYPE html>
<html>
<head>
<script src="http://domain-name.co.uk/js/theirscript.js"></script>
</head>
<body>
<iframe src='http://domain-name.co.uk/quote/quote_0.numo?id=mySplID' id="ifHolderQuote" width="660" frameBorder="0" marginwidth="0" marginheight="0" scrolling="no" allowTransparency="true" onload="resizeCrossDomainIframe('ifHolderQuote', 'http://mySplDomain.co.uk');">
</iframe>
</body>
</html>
但由于某种原因,当我使用浏览器查看纯 HTML 文件时,我无法完全看到它。它只显示这样的一小部分。
但是在他们网站上传的实际测试文件中,我可以查看完整的 iFrame。
知道如何修复我的代码以反映更改吗?这是使用的脚本。
function resizeCrossDomainIframe(id, other_domain) {
var iframe = document.getElementById(id);
window.addEventListener('message', function(event) {
if (event.origin !== other_domain) return; // only accept messages from the specified domain
if (isNaN(event.data)) return; // only accept something which can be parsed as a number
var height = parseInt(event.data) + 40; // add some extra height to avoid scrollbar
iframe.height = height + "px";
}, false);
}
编辑:我将文件上传到服务器,看看从浏览器本地打开它是否有问题,即使上传到服务器后它也不起作用。
【问题讨论】:
标签: javascript html iframe