iFrame on iPhone
I am trying to create a toolbar on top of my website to be used on an iphone. However, iframe is giving me considerable trouble in that it refuses to allow the page to scroll. Here's my code:
<iframe id="myIFrame" src="http://www.bloomberg.com"
runat="server" frameborder="0" style="position: fixed; top: 65px; left: 0px; width: 100%; overflow:auto;"></iframe>
<script type="text/javascript">
window.onresize = setHeight;
function setHeight() {
var myScreenHeight = screenHeight();
var theIFrame = document.getElementById("myIFrame");
开发者_如何学编程theIFrame.height = myScreenHeight - document.getElementById("toolbar").clientHeight + "px";
return false;
}
function screenHeight() {
var myHeight = 0;
if (typeof (window.innerWidth) == 'number') {
myHeight = window.innerHeight;
} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
myHeight = document.documentElement.clientHeight;
}
return myHeight;
}
jQuery(document).ready(setHeight);
</script>
Any ideas?
It is not possible to have native scrolling, and fixed position toolbars in webkit on iphone.
This javascript plugin tackles that exact issue by replicating the scrolling and allowing fixed position toolbars: http://cubiq.org/iscroll-4
精彩评论