導航:首頁 > 編程語言 > javascriptscreen

javascriptscreen

發布時間:2024-10-09 02:49:34

『壹』 js裡面獲取屏幕寬高的screen對象,為什麼獲取不了屏幕的寬高值

<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8">

<title>
RunJS演示代碼
</title>
<styletype="text/css">
body,div{
margin:0px;
padding:0px;
}
#show{
width:400px;
height:400px;
margin:100pxauto;
background:#969696;
text-align:center;
}
</style>
<scripttype="text/javascript">
functionmess(){
varstr="屏幕尺寸基本信息:<br/>";//這里你是中文的分號,故而報錯
str+="屏幕寬度:"+screen.width+"像素<br/>";
str+="屏幕高度:"+screen.height+"像素<br/>";
str+="屏幕可用寬度"+screen.availWidth+"像素<br/>";
str+="屏幕可用高度"+screen.availHeight+"像素<br/>";
document.getElementById("show").innerHTML=str;
}
</script>
</head>
<bodyonload="mess()">
<divid="show">
</div>
</body>
</html>

『貳』 JavaScript中如何獲取手機瀏覽器的大小

JavaScript不管是判斷PC瀏覽器還是手機瀏覽器,都是通過User Agent 來判斷

var ua = navigator.userAgent;

取得大小可內以試下
var screenAW = window.screen.availWidth;
var screenAH = window.screen.availHeight;
或者容
var screenW = window.screen.width;
var screenH = window.screen.height;

閱讀全文

與javascriptscreen相關的資料

熱點內容
怎麼看公司網路是什麼時候開通 瀏覽:960
cad2015文件參照怎麼關閉 瀏覽:678
最小二乘逼近程序 瀏覽:610
鐵路12306密碼找不回 瀏覽:352
默認網路覆蓋的腦區 瀏覽:319
itunes恢復iphone教程 瀏覽:292
爐石現在是什麼版本 瀏覽:825
word兼容包安裝報錯 瀏覽:528
iphone5s包裝4g沒有氣孔 瀏覽:814
html包含文件代碼嗎 瀏覽:50
蘋果appstore日本賬號 瀏覽:532
解密dg加密的文件 瀏覽:206
gsh6什麼格式文件 瀏覽:507
dnf85版本覺醒任務 瀏覽:998
范冰冰蘋果百度雲盤資源鏈接 瀏覽:507
資料庫主機是什麼系統 瀏覽:812
pdf表單教程 瀏覽:715
百度瀏覽器去更新安卓破解版 瀏覽:855
光碟內部應用程序錯誤 瀏覽:83
iphone6升級ios9步驟 瀏覽:873

友情鏈接