好的。我决定看看发生了什么,并使用curl通过android视图获取源代码。
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.actwebdesigns.co.uk');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; U; Android 1.1; en-gb; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2');
$html = curl_exec($ch);
echo $html;
具有横向或纵向类的唯一元素是html标记。
<html xmlns="http://www.w3.org/1999/xhtml" class="ui-mobile landscape min-width-320px min-width-480px min-width-768px min-width-1024px"><head><meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1"></html>
我也注意到,框架不会自动切换旋转类,所以下面的代码,我已经测试的作品。
<script type="text/javascript">
$(window).resize(function(){
$('html').toggleClass('landscape, portrait');
});
</script>
报废上述有缺陷。
<script type="text/javascript">
$(window).resize(function(){
var height = $(window).height();
var width = $(window).width();
var ob = $('html');
if(width > height) {
if(ob.hasClass('portrait')) {
ob.removeClass('portrait').addClass('landscape');
}
}else{
if(ob.hasClass('landscape')) {
ob.removeClass('landscape').addClass('portrait');
}
}
});
</script>
使用从Tommi Laukkanen's脚本以上工作正常。
jQuery Mobile的做这个自动为您。 – dave1010 2011-03-01 16:46:59