【发布时间】:2013-01-06 15:35:22
【问题描述】:
我正在尝试在iOS上滚动一个iframe,我成功了,它滚动得很好,参考:
http://home.jejaju.com/play/iframe-scroll.html
http://areaaperta.com/nicescroll/demo.html
但是,所有解决方案都有一个问题:iframe 页面没有完全显示...
我在我的 iphone 和 ipad 上进行了测试,iframe 页面显示不稳定。
有什么想法吗?
例子:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9;FF=3;chrome=1;OtherUA=4" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.js"></script>
<script type="text/javascript">
$(function(){
if (/iPhone|iPod|iPad/.test(navigator.userAgent))
$('iframe').wrap(function(){
var $this = $(this);
return $('<div />').css({
width: $this.attr('width'),
height: $this.attr('height'),
overflow: 'scroll',
'-webkit-overflow-scrolling': 'touch'
});
});
})
</script>
<title>Untitled</title>
</head>
<body>
stuff
<div>
<iframe src="iframe-scroll-long.html" height="500" width="500"></iframe>
</div>
more stuff
</body>
</html>
【问题讨论】:
-
我的代码和home.jejaju.com/play/iframe-scroll.html一样,你可以在iPad上看到这个页面,iframe页面显示断断续续,我的iOS版本是5.1.1。
-
好的,但是我不能查看源代码,你能把那个网页的代码贴出来吗?
-
当我在 itouch 上查看时,它看起来不错
-
嗨 Abe,我现在添加代码。 iframe 页面在第一个屏幕上看起来不错,但是当我向下滚动时,会显示不完整的页面。
-
我看到这里没有右大括号:$('iframe').wrap(function(){ 在function这个词之后,这可能是问题吗?
标签: html cordova iframe web-applications jquery-plugins