Ⅰ javascript或php如何獲取當前用戶屏幕的物理尺寸
您好:
<html>
<script>
function a(){
document.write(
"屏幕解析度為:"+screen.width+"*"+screen.height
+"<br />"+
"屏幕可用大小:"+screen.availWidth+"*"+screen.availHeight
+"<br />"+
"網頁可見區域寬:"+document.body.clientWidth
+"<br />"+
"網頁可見區域高:"+document.body.clientHeight
+"<br />"+
"網頁可見區域寬(包括邊線的寬):"+document.body.offsetWidth
+"<br />"+
"網頁可見區域高(包括邊線的寬):"+document.body.offsetHeight
+"<br />"+
"網頁正文全文寬:"+document.body.scrollWidth
+"<br />"+
"網頁正文全文高:"+document.body.scrollHeight
+"<br />"+
"網頁被捲去的高:"+document.body.scrollTop
+"<br />"+
"網頁被捲去的左:"+document.body.scrollLeft
+"<br />"+
"網頁正文部分上:"+window.screenTop
+"<br />"+
"網頁正文部分左:"+window.screenLeft
+"<br />"+
"屏幕解析度的高:"+window.screen.height
+"<br />"+
"屏幕解析度的寬:"+window.screen.width
+"<br />"+
"屏幕可用工作區高度:"+window.screen.availHeight
+"<br />"+
"屏幕可用工作區寬度:"+window.screen.availWidth
);
}
</script>
<body on
load="a()" >
</body>
</html>
您要用這個尺寸的話,只要用可用大小來顯示就可以了。就是第二個屏幕可用大小。
Ⅱ 用javascript 怎樣才能很好的獲取手機的屏幕寬度和高度
無論是手機端還是 PC 端,瀏覽器的寬高使用
document.documentElement.clientWidth
document.documentElement.clientHeight
都是兼容性很好的
screen.width啥的應該也版沒問題
可以上w3school網站找權找相關的資料
Ⅲ js和jquery獲取各種屏幕的寬度和高度
Javascript:
網頁可見區域寬:
document.body.clientWidth
網頁可見區域高:
document.body.clientHeight
網頁可見區域寬:
document.body.offsetWidth
(包括邊線的寬)
網頁可見區域高:
document.body.offsetHeight
(包括邊線的高)
網頁正文全文寬:
document.body.scrollWidth
網頁正文全文高:
document.body.scrollHeight
網頁被捲去的高:
document.body.scrollTop
網頁被捲去的左:
document.body.scrollLeft
網頁正文部分上:
window.screenTop
網頁正文部分左:
window.screenLeft
屏幕解析度的高:
window.screen.height
屏幕解析度的寬:
window.screen.width
屏幕可用工作區高度:
window.screen.availHeight
屏幕可用工作區寬度:
window.screen.availWidth
JQuery:
$(document).ready(function(){
alert($(window).height());
//瀏覽器當前窗口可視區域高度
alert($(document).height());
//瀏覽器當前窗口文檔的高度
alert($(document.body).height());//瀏覽器當前窗口文檔body的高度
alert($(document.body).outerHeight(true));//瀏覽器當前窗口文檔body的總高度
包括border
padding
margin
alert($(window).width());
//瀏覽器當前窗口可視區域寬度
alert($(document).width());//瀏覽器當前窗口文檔對象寬度
alert($(document.body).width());//瀏覽器當前窗口文檔body的寬度
alert($(document.body).outerWidth(true));//瀏覽器當前窗口文檔body的總寬度
包括border
padding
margin
})
Ⅳ javascript如何獲取頁面的高度和寬度
window.outerHeight 窗口總高度 和window.screen.availHeight一樣
window.innerHeight 窗口可視區域高度
window.screen.height 顯示器屏幕高版度
另外:權jquery獲取高度
$(".thisCrumbs").height()
元素本身高度
$(".thisCrumbs").innerHeight()
元素高度+內邊距
$(".thisCrumbs").outerHeight()
元素高度+內邊距+邊框
$(".thisCrumbs").outerHeight(true)
元素高度+內邊距+邊框+外邊距
Ⅳ 如何用JAVASCRIPT獲取當前窗口的高度和寬度
<body><SCRIPTLANGUAGE="JavaScript">
vars="";
s+=" 網頁可見區域寬:"+document.body.clientWidth;
s+=" 網頁可見區域高:"+document.body.clientHeight;
s+=" 網頁可見區域寬:"+document.body.offsetWidth+"(包括邊線和滾動條的寬)";
s+=" 網頁可見區域高:"+document.body.offsetHeight+"(包括邊線的寬)";
s+=" 網頁正文全文寬:"+document.body.scrollWidth;
s+=" 網頁正文全文高:"+document.body.scrollHeight;
s+=" 網頁被捲去的高:"+document.body.scrollTop;
s+=" 網頁被捲去的左:"+document.body.scrollLeft;
s+=" 網頁正文部分上:"+window.screenTop;
s+=" 網頁正文部分左:"+window.screenLeft;
s+=" 屏幕解析度的高:"+window.screen.height;
s+=" 屏幕解析度的寬:"+window.screen.width;
s+=" 屏幕可用工作區高度:"+window.screen.availHeight;
s+=" 屏幕可用工作區寬度:"+window.screen.availWidth;
s+=" 你的屏幕設置是"+window.screen.colorDepth+"位彩色";
s+=" 你的屏幕設置"+window.screen.deviceXDPI+"像素/英寸";
alert(s);
</SCRIPT>
拿去 看看有沒有你要的
Ⅵ 關於JS獲取(判斷)不同屏幕大小,並根據屏幕的大小,調用不同的CSS,求大神給我一個例子,我看下。
下邊是JS獲得屏幕大小的方法,調用不同的CSS是給某個對象,設置不同CSS樣式嗎?
你最好說明你想要的效果。
<html>
<script>
function a(){
document.write(
"屏幕解析度為:"+screen.width+"*"+screen.height
+"<br />"+
"屏幕可用大小:"+screen.availWidth+"*"+screen.availHeight
+"<br />"+
"網頁可見區域寬:"+document.body.clientWidth
+"<br />"+
"網頁可見區域高:"+document.body.clientHeight
+"<br />"+
"網頁可見區域寬(包括邊線的寬):"+document.body.offsetWidth
+"<br />"+
"網頁可見區域高(包括邊線的寬):"+document.body.offsetHeight
+"<br />"+
"網頁正文全文寬:"+document.body.scrollWidth
+"<br />"+
"網頁正文全文高:"+document.body.scrollHeight
+"<br />"+
"網頁被捲去的高:"+document.body.scrollTop
+"<br />"+
"網頁被捲去的左:"+document.body.scrollLeft
+"<br />"+
"網頁正文部分上:"+window.screenTop
+"<br />"+
"網頁正文部分左:"+window.screenLeft
+"<br />"+
"屏幕解析度的高:"+window.screen.height
+"<br />"+
"屏幕解析度的寬:"+window.screen.width
+"<br />"+
"屏幕可用工作區高度:"+window.screen.availHeight
+"<br />"+
"屏幕可用工作區寬度:"+window.screen.availWidth
);
}
</script>
<body onload="a()" >
</body>
</html>
Ⅶ js如何獲取屏幕英寸(注意不是獲取解析度像素值啊)
你用捲尺量顯示屏的有效發光顯示面的對角線尺寸,記下有多少寸,然後用這個尺寸換算成英寸就可以了!