由于公司里的很多东西都要用到iframe 导致我不得不各种百度
首先是自适应高度
// document.domain = "caibaojian.com";
function setIframeHeight(iframe) {
if (iframe) {
var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
if (iframeWin.document.body) {
iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
}
}
}; window.onload = function () {
setIframeHeight(document.getElementById('external-frame'));
};
其他的请到这个链接下查看:http://caibaojian.com/iframe-adjust-content-height.html
还有一个就是iframe 里的右键禁用方法:
<script>
document.oncontextmenu = function(){
return false
}
</script>
这段代码需要放在iframe内部才能生效