Created
May 27, 2013 08:06
-
-
Save janily/5655758 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, 200); | |
}; | |
iframeHeight(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment