您的位置:首頁>正文

JS|獲取流覽器和視窗屬性資料

1 JS獲取流覽器屬性資料

你目前所使用的流覽器的資料:

使用chrome顯示網頁內容如下:

使用firefox顯示網頁內容如下:

2 JS獲取視窗資料

流覽器視窗資料:

右邊的資料反映流覽器視窗高寬的資料(單位是px,不包括上端的功能表列和工具列, 也不包括下端的狀態列;按F11全屏顯示或“還原”按鈕並調整大小也會有不同的資料回饋。 )

流覽器窗口的實際高度:

流覽器窗口的實際寬度:

獲取視窗大小

if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)

{

winHeight = document.documentElement.clientHeight;

winWidth = document.documentElement.clientWidth;

}

//結果輸出至兩個文字方塊

document.form1.availHeight.value= winHeight;

document.form1.availWidth.value= winWidth;

}

findDimensions();

//調用函數, 獲取數值

window.onresize=findDimensions;

使用chrome顯示網頁內容如下:

使用firefox顯示網頁內容如下:

-End-

同類文章
Next Article
喜欢就按个赞吧!!!
点击关闭提示