Javascript iPhone上的iFrame
我正在尝试在我的网站顶部创建一个工具栏,以便在iphone上使用。然而,iframe给我带来了相当大的麻烦,因为它拒绝允许页面滚动。这是我的密码:Javascript iPhone上的iFrame,javascript,jquery,asp.net,html,Javascript,Jquery,Asp.net,Html,我正在尝试在我的网站顶部创建一个工具栏,以便在iphone上使用。然而,iframe给我带来了相当大的麻烦,因为它拒绝允许页面滚动。这是我的密码: <iframe id="myIFrame" src="http://www.bloomberg.com" runat="server" frameborder="0" style="position: fixed; top: 65px; left: 0px; width: 100%; overflow:auto;"></i
<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>
window.onresize=setHeight;
函数setHeight(){
var myScreenHeight=屏幕高度();
var theIFrame=document.getElementById(“myIFrame”);
theIFrame.height=myScreenHeight-document.getElementById(“工具栏”).clientHeight+“px”;
返回false;
}
函数屏幕高度(){
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;
}
返回我的高度;
}
jQuery(document).ready(setHeight);
有什么想法吗?在iphone的webkit中不可能有本机滚动和固定位置工具栏
这个javascript插件通过复制滚动并允许固定位置的工具栏来解决这个问题:对于一个愚蠢的工具栏来说,这似乎有点过头了。一般来说,有没有更简单的方法来使用工具栏?如果您希望工具栏在滚动时保持在那里,就没有了。这是最简单的方法——我已经研究过了。如果您正在制作一个本机应用程序,您可以创建一个与滚动区域大小相同的web视图,并且它可以按照您想要的方式工作,但作为一个网站,这是不可能的。如果我不希望它在滚动时停留在那里怎么办?您可以使用两个手指在Mobile Safari中滚动iFrame。