當前位置:編程學習大全網 - 源碼下載 - jquery怎麽獲取瀏覽器屏幕分辨率

jquery怎麽獲取瀏覽器屏幕分辨率

<script type="text/javascript">

$(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

alert(screen.height);//顯示器分辨率,只能用JavaScript代碼獲取

alert(screen.width);

})

</script>

網頁可見區域寬: 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

這個是文件源代碼

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"?

".js" type="text/javascript"></script>

<style type="text/css">

* { font-family: Verdana; font-size: 96%; }

label { width: 10em; float: left; }

label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }

p { clear: both; }

.submit { margin-left: 12em; }

em { font-weight: bold; padding-right: 1em; vertical-align: top; }

</style>

<script type="text/javascript">

$(document).ready(function(){

$("#commentForm").validate({

rules: {

username: {

required: true,

minlength: 2

},

email: {

required: true,

email: true

},

url:"url",

comment: "required"

}

});

});

</script>

</head>

<body>

<form class="cmxform" id="commentForm" method="get" action="">

<fieldset>

<legend>壹個簡單的驗證帶驗證提示的評論例子</legend>

<p>

<label for="cusername">姓名</label>

<em>*</em><input id="cusername" name="username" size="25" />

</p>

<p>

<label for="cemail">電子郵件</label>

<em>*</em><input id="cemail" name="email" size="25" />

</p>

<p>

<label for="curl">網址</label>

<em> </em><input id="curl" name="url" size="25" value="" />

</p>

<p>

<label for="ccomment">妳的評論</label>

<em>*</em><textarea id="ccomment" name="comment" cols="22"></textarea>

</p>

<p>

<input class="submit" type="submit" value="提交"/>

</p>

</fieldset>

</form>

</body>

</html>

現在的問題是 在IE瀏覽器是可以驗證的 在遨遊 360等瀏覽器裏面直接用瀏覽器打開也是可以驗證的,但是用?選項,把安全級別和隱私級別都設置為中,就好了。

  • 上一篇:Red Flag Linux Desktop 無法執行(很多很多...)exe
  • 下一篇:springcloud com.netflix.client.ClientException: null 解決方案
  • copyright 2024編程學習大全網