導航:首頁 > 編程語言 > 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相關的資料

熱點內容
源文件名太長什麼意思 瀏覽:573
linux文件復制到u盤 瀏覽:141
4558升級代換 瀏覽:589
泰國支持什麼網路 瀏覽:939
ps鉛筆畫用什麼工具上色 瀏覽:108
5s升級ios93會不會卡 瀏覽:775
驅動安裝完了找不到文件夾 瀏覽:717
金醫保app可以預約哪些醫院 瀏覽:840
如果快速刪掉電腦桌面文件 瀏覽:309
網路優化系統是什麼 瀏覽:320
海康威視數據怎麼刪除 瀏覽:826
ug編程哪個視圖好用 瀏覽:866
福州龍泉哪裡有學編程的 瀏覽:513
消保整改文件 瀏覽:145
重度貧血數據是多少 瀏覽:323
maya粒子表達式教程 瀏覽:84
抖音小視頻如何掛app 瀏覽:283
cad怎麼設置替補文件 瀏覽:790
win10啟動文件是空的 瀏覽:397
jk網站有哪些 瀏覽:134

友情鏈接