Skip to content

Instantly share code, notes, and snippets.

@janily
Created May 27, 2013 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save janily/5655758 to your computer and use it in GitHub Desktop.
Save janily/5655758 to your computer and use it in GitHub Desktop.
iframe
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