ios webview中关于宽高的总结

测试一

测试的物料:

<html>

<head>

<meta charset="UTF-8">

<meta name="viewport" content="initial-scale=0.5 user-scalable=no" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>SMAdUnit</title>

</head>

<body style="margin:0px auto; padding:0; overflow:hidden; background-color:transparent;"><p>

<a href="http://appsrv1.madserving.com/cli2/lgkrp9de65881hl5rl30066fjiv46q6881bqupb25bee2ec..MzY5MDQxMg.c46ab76d2859.ODY2Mjc4MDE..ODY2Mjc4MDEzNjkwNDEy...-1-1hlx5d/napi1.0.0000/90042385"><img src="http://ws-cdn.tangmobile.com/2009/smartmad2/20/52/25bee2ec.jpg" /></a></p>

</body>

<script type="text/javascript">

function loadimagefinish(){

console.log(‘document.body.clientWidth ‘ + document.body.clientWidth);

console.log(‘document.body.clientHeight ‘ + document.body.clientHeight);

console.log(‘window.screen.height ‘ + window.screen.height);

console.log(‘window.screen.width ‘ + window.screen.width);

console.log(‘window.screen.availHeight ‘ + window.screen.availHeight);

console.log(‘window.screen.availWidth ‘ + window.screen.availWidth);

console.log(‘window.innerWidth ‘ + window.innerWidth);

console.log(‘window.innerHeight ‘ + window.innerHeight);

console.log(‘window.outerWidth ‘ + window.outerWidth);

console.log(‘window.outerHeight ‘ + window.outerHeight);

console.log(‘window.screenLeft ‘ + window.screenLeft);

console.log(‘window.screenTop ‘ + window.screenTop);

console.log(‘window.screenY ‘ + window.screenY);

console.log(‘window.screenX ‘ + window.screenX);

}

var timerid = window.setInterval(loadimagefinish,5000);

</script>

</html>

webview 设置为300*280

测试设备 iPad

这是使用safair调试截图:

测试二

测试的物料:

<html>

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, user-scalable=no">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>SMAdUnit</title>

</head>

<body style="margin:0px auto; padding:0; overflow:hidden; background-color:transparent;"><p>

<a href="http://appsrv1.madserving.com/cli2/lgkrp9de65881hl5rl30066fjiv46q6881bqupb25bee2ec..MzY5MDQxMg.c46ab76d2859.ODY2Mjc4MDE..ODY2Mjc4MDEzNjkwNDEy...-1-1hlx5d/napi1.0.0000/90042385"><img src="http://ws-cdn.tangmobile.com/2009/smartmad2/20/52/25bee2ec.jpg" /></a></p>

</body>

<script type="text/javascript">

function loadimagefinish(){

console.log(‘document.body.clientWidth ‘ + document.body.clientWidth);

console.log(‘document.body.clientHeight ‘ + document.body.clientHeight);

console.log(‘window.screen.height ‘ + window.screen.height);

console.log(‘window.screen.width ‘ + window.screen.width);

console.log(‘window.screen.availHeight ‘ + window.screen.availHeight);

console.log(‘window.screen.availWidth ‘ + window.screen.availWidth);

console.log(‘window.innerWidth ‘ + window.innerWidth);

console.log(‘window.innerHeight ‘ + window.innerHeight);

console.log(‘window.outerWidth ‘ + window.outerWidth);

console.log(‘window.outerHeight ‘ + window.outerHeight);

console.log(‘window.screenLeft ‘ + window.screenLeft);

console.log(‘window.screenTop ‘ + window.screenTop);

console.log(‘window.screenY ‘ + window.screenY);

console.log(‘window.screenX ‘ + window.screenX);

}

var timerid = window.setInterval(loadimagefinish,5000);

</script>

</html>

webview 设置为300*280

测试设备 iPad

这是使用safair调试截图:

比较两个物料发现

物料一

<meta name="viewport" content="initial-scale=0.5 user-scalable=no" />

物料二

<meta name="viewport" content="width=device-width, user-scalable=no">

个人认为:由于设置了viewport导致物料二中document.body.clientWidth 返回宽度是设备的宽度,document.body.clientHeight 高度按照300*280的比例等比例放大了 280*(768/300)=716.8(约等于717)

获取webview的实际宽度可以考虑使用window.innerWidth,window.innnerHeight.(资料现实这两个返回的值不包括边框宽度)

时间: 2024-08-28 12:09:51

ios webview中关于宽高的总结的相关文章

js中各种宽高

各种宽高 Javascript: IE中:document.body.clientWidth ==> BODY对象宽度document.body.clientHeight ==> BODY对象高度document.documentElement.clientWidth ==> 可见区域宽度document.documentElement.clientHeight ==> 可见区域高度FireFox中:document.body.clientWidth ==> BODY对象宽度

第76天:jQuery中的宽高

Window对象和document对象的区别 1.window对象表示浏览器中打开的窗口 2.window对象可以省略,比如alert()也可以写成window.alert() Document对象是window对象的一部分 浏览器的HTML文档成为dicument对象 Window.location和document.location Window对象的location属性饮用的是location对象,表示该窗口中当前显示文档的URL Document对象的location属性也是引用了loc

js/jQuery中的宽高

一.和window有关的宽高 window.innerWidth:浏览器窗口宽度 window.innerHeight:浏览器窗口高度(不包括导航,工具栏等的高度) window.outerWidth:浏览器窗口宽度(很多时候===window.innerWidth) window.outerHeight:浏览器窗口高度(包括导航,工具栏等的高度) window.screen.width:用户设备屏幕的宽度 window.screen.height:用户设备屏幕的高度 window.screen

JS中的宽高(基础知识很重要)

IE中:document.body.clientWidth ==> BODY对象宽度document.body.clientHeight ==> BODY对象高度document.documentElement.clientWidth ==> 可见区域宽度document.documentElement.clientHeight ==> 可见区域高度FireFox中:document.body.clientWidth ==> BODY对象宽度document.body.cli

Adatper中获取宽高为0的问题

但是我们想在getView()中获取ImageView的宽和高存在问题,在getView()里面刚开始显示item的时候利用ImageView.getWidth() 获取的都是0,为什么刚开始获取不到宽和高呢,因为我们使用LayoutInflater来将XML布局文件Inflater()成View的时候,View并没有显示在界面上面,表明并没有对View进行onMeasure(), onLayout(), onDraw()等操作,必须等到retrue convertView的时候,表示该item

css中盒子宽高的auto

CSS盒模型中,auto属性只适用于外margin和width,border和padding不适用.下面就来说说它的情况.这里所说的都是标准流盒子. 1.横向来说 (1)若设置width,magrin-left,margin-right中某个值为auto,剩下两个为指定值,则设为auto的属性会确定所需的长度,从而使元素的宽度等于父元素的width.例如,盒的横向长度必须等于400px,没有设置padding和border,margin-right和width设置为100px,左外边距设置为au

js中获取宽高

<script type="text/javascript"> function getWH() { var a = ""; a += " 网页可见区域宽:" + document.body.clientWidth + "\n"; a += " 网页可见区域高:" + document.body.clientHeight + "\n"; a += " 网页可见区域宽

IOS webview中cookie的读取与保存-b

Cookie 的读取 将它放在 webViewDidFinishLoad 开始后执行 NSArray *nCookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];NSHTTPCookie *cookie; for (id c in nCookies) { if ([c isKindOfClass:[NSHTTPCookie class]]){ cookie=(NSHTTPCookie *)c; NSLog(@"%@: %

H.264从SPS中提取视频宽高

H.264有两种封装模式: (1)annexb模式:传统模式,使用start code来分隔NAL, SPS和PPS是在ES流的头部: (2)mp4模式:没有start code,使用NALU长度(固定字节,通常为4个字节)来分隔NAL.AVCodecContext的extradata内部保存着分隔的字节数,SPS和PPS: 1. 找到SPS 视频的宽高保存在SPS中.那么提取宽高首先要找到SPS.annexb模式直接读取视频数据,根据NAL type找到SPS即可.mp4模式应该从extrad