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

熱點內容
ps3文件分割視頻 瀏覽:280
微信圖片一鍵轉發軟體 瀏覽:331
如何判斷s200plc編程電纜 瀏覽:691
太原編程培訓班哪個好 瀏覽:171
樹葉吹奏教程 瀏覽:6
社交app帶來了哪些社會問題 瀏覽:394
如何安裝愛寶8800數據採集器 瀏覽:712
文件保存了怎麼找不到了 瀏覽:476
彩票網站怎麼辨真假 瀏覽:840
pr找不到該文件 瀏覽:963
java移除panel 瀏覽:354
jsp填充jsp 瀏覽:166
海關外貿大數據在哪裡查 瀏覽:381
思特奇java筆試題 瀏覽:121
葫蘆俠在手機中的文件名 瀏覽:813
plc編程應該怎麼收錢 瀏覽:584
c語言中源文件由什麼組成 瀏覽:890
linuxhttpdphp配置文件 瀏覽:607
拆單數據要怎麼保存 瀏覽:17
mac電腦怎樣壓縮文件到100m 瀏覽:645

友情鏈接