测试一

测试的物料:

<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.(资料现实这两个返回的值不包括边框宽度)

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

  1. 【IE6的疯狂之一】IE6中奇数宽高的BUG

    IE6真是太疯狂了.今天由于项目需要做了这么一个布局:一个外部的相对定位div,内部一个绝对定位的div(right:0), 如图: 可是在IE6下查看,却变成了right:1px的效果了: IE6还 ...

  2. canvas基础入门(一)canvas的width、height于css样式中的宽高区别

    canvas的width.height于css样式中的宽高对画布的内容显示是有所区别的 1.在canvas标签下调用他的width和height,而且是没有单位的宽高,这种指定canvas大小的方法也 ...

  3. iOS硬解码获取宽高

    1: CVPixelBufferGetWidth(_:The pixel buffer whose width you want to obtain) 获取解码后图像宽度 CVPixelBufferG ...

  4. js中各种宽高

    各种宽高 Javascript: IE中:document.body.clientWidth ==> BODY对象宽度document.body.clientHeight ==> BODY ...

  5. DOM中获取宽高、位置总结

    原生JS 一.文档.窗口的宽高和位置 // 获取屏幕的宽高 window.screen.height | window.screen.width // 屏幕可用工作区宽高 window.screen. ...

  6. 第76天:jQuery中的宽高

    Window对象和document对象的区别 1.window对象表示浏览器中打开的窗口 2.window对象可以省略,比如alert()也可以写成window.alert() Document对象是 ...

  7. js/jQuery中的宽高

    一.和window有关的宽高 window.innerWidth:浏览器窗口宽度 window.innerHeight:浏览器窗口高度(不包括导航,工具栏等的高度) window.outerWidth ...

  8. jquery操作html中图片宽高自适应

    在网站制作中如果后台上传的图片不做宽高限制,在前台显示的时候,经常会出现图片变形,实用下面方法可以让图片根据宽高自适应,不论是长图片或者高图片都可以完美显示. $("#myTab0_Cont ...

  9. IE6中奇数宽高的BUG

    一个外部的相对定位div,内部一个绝对定位的div(right:0), 如图: 可是在IE6下查看,却变成了right:1px的效果了: IE6还有奇数宽高的bug,解决方案就是将外部相对定位的div ...

随机推荐

  1. malloc函数详解

    一.原型:extern void *malloc(unsigned int num_bytes); 头文件:#include <malloc.h> 或 #include <alloc ...

  2. easyui-textbox 和 easyui-validatebox 设置值和获取值

    表单作如下定义:该input使用easyui的"easyui-textbox" <input id="addSnumber" style="wi ...

  3. Java成员初始化顺序

    //类装载时: 1, 基类static成员 2, 派生类static成员 //创建对象时: 3, 基类构造函数 4, 派生类构造函数

  4. Create Linked Server SQL Server 2008

    From:http://www.jensbits.com/2010/11/10/create-linked-server-sql-server-2008/ http://www.c-sharpcorn ...

  5. oracle 11g 一直提示 严重: 监听程序未启动或数据库服务未注册到该监听程序

    From:http://blog.sina.com.cn/s/blog_6734ea6d0102v6sn.html 增加操作系统环境变量:ORACLE_HOSTNAME=localhost 然后在cm ...

  6. 正则表达式学习与python中的应用

    目录: 一.正则表达式的特殊符号 二.几种重要的正则表达式 三.python的re模块应用 四.参考文献 一.正则表达式的特殊符号 特殊符号可以说是正则表达式的关键,掌握并且可以灵活运用重要的pyth ...

  7. String类实现

    String类是应用框架中不可或缺的类 重载运算符实现字符串的操作 #idndef IOTECK_STRING_H_#define IOTECK_STRING_H_namespace iotek{ c ...

  8. HttpURLConnection网络请求

    //创建访问的方法 public String Check_json(){ //创建一个结果字符串 String result=""; //拼接字符串 StringBuffer s ...

  9. tar.gz file installation

    1. tar xzvf  filename.tar.gz 2. cd filename 3. ./configure ./configure --prefix="path" 4. ...

  10. 制作.frameWork的最全最真实的解决办法

    这个制作流程 本博主 已经完全测试成功 我这边 制作的.frameWork 要接入游戏 我们游戏已经上架 所以这个东西完全可以用 http://www.cocoachina.com/bbs/read. ...