-
-
Save themorgantown/bde3b0a86a82dd77a7aa7695cc3a8681 to your computer and use it in GitHub Desktop.
iframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTML代码: | |
<iframe id="testIframe" frameborder="0" scrolling="no" src="iframe-page-no-fresh.html" width="100%" height="120"></iframe> | |
JS代码: | |
//高度自适应 | |
var iframe = document.getElementById("testIframe"); | |
var iframeHeight = function() { | |
var hash = window.location.hash.slice(1), h; | |
if (hash && /height=/.test(hash)) { | |
h = hash.replace("height=", ""); | |
iframe.height = h; | |
} | |
setTimeout(iframeHeight, 2000); | |
}; | |
iframeHeight(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment