Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果html中的if子句带有CSS标记max device width,是否可能?_Javascript_Iphone_Html_Css_Uiwebview - Fatal编程技术网

Javascript 如果html中的if子句带有CSS标记max device width,是否可能?

Javascript 如果html中的if子句带有CSS标记max device width,是否可能?,javascript,iphone,html,css,uiwebview,Javascript,Iphone,Html,Css,Uiwebview,我有一个通用iOS项目,在这个项目中,我必须在UIWebView中显示一些本地存储的html页面 要调整html内容大小,我必须在html标签中使用: <meta name ="viewport" content = "width = 703, user-scalable=no "> \\for the iPad 及 有没有一种方法可以在html的标题中添加如下内容: if( max-device-width == 480) { <meta name ="viewp

我有一个通用iOS项目,在这个项目中,我必须在UIWebView中显示一些本地存储的html页面

要调整html内容大小,我必须在html标签中使用:

<meta name ="viewport" content = "width = 703, user-scalable=no "> \\for the iPad

有没有一种方法可以在html的标题中添加如下内容:

if( max-device-width == 480) {
     <meta name ="viewport" content = "width = device-width, user-scalable=no ">
}
else {
   <meta name ="viewport" content = "width = 703, user-scalable=no ">
}
有没有办法在HTML或JS中实现这一点?我对html和js只有一些基本的概念,所以如果能帮我做到这一点,我将不胜感激


谢谢大家!

您应该能够查询窗口大小,但必须小心,并用从JavaScript结果中获得的值替换宽度值。一定要阅读上面提到的quirksmode帖子。[如果你真的担心结果,你可以考虑使用像jQuery这样的JavaScript库,它应该为你处理所有的浏览器案例。]用户可扩展性=No可以附加到设置内容的值。

你应该和QuiksStand站点上的其他文章一起阅读。他有很多关于如何处理这类事情的信息。
if( max-device-width == 480) {
     <meta name ="viewport" content = "width = device-width, user-scalable=no ">
}
else {
   <meta name ="viewport" content = "width = 703, user-scalable=no ">
}