很简单,我需要的白框的高度和宽度正好与iframe的文本,我可怎么办呢?
function resizeIframe (iframeContentWidth, iframeContentHeight) {
var container = window.frameElement.parentElement;
if (container != parent.document.body) {
container.style.width = iframeContentWidth + 'px';
container.style.height = iframeContentHeight + 'px';
}
window.frameElement.style.width = iframeContentWidth + 'px';
window.frameElement.style.height = iframeContentHeight + 'px';
return;
}
html {
background-color: #fff
}
div {
background-color: #000;
display: inline-block;
}
<div>
<iframe src="http://190.216.202.35/rxp/mobilpxr.php?stopid=502102" height="85px" width="250px" scrolling="no" frameborder="0">
</div>
如果IFRAME源不在[同一域(HTTPS://developer.mozilla。 org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript)与父页面,没有什么可以做的。 – Teemu
是同一个域 –
然后[this](http://stackoverflow.com/a/11807287/1169519)可能有帮助吗?虽然我不知道,但如何计算页面的重量(=质量); )。可能你的意思是“宽度”? – Teemu