小迪的Blog
学习ing...(注明:该Blog中的任何信息都非原创,只是作为个人的阅读笔记)

JavaScript--检测分辨率

以下代码加入<HEAD>区:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function redirectPage() {
var url640x480 = "http://www.17357.net/640x480";**记得改相应的页面
var url800x600 = "http://www.17357.net/800x600";
var url1024x768 = "http://www.17357.net/1024x768";
if ((screen.width == 640) && (screen.height == 480))
window.location.href= url640x480;
else if ((screen.width == 800) && (screen.height == 600))
window.location.href= url800x600;
else if ((screen.width == 1024) && (screen.height == 768))
window.location.href= url1024x768;
else window.location.href= url640x480;
}
// End -->
</script>

以下代码加入<BODY>区:
<center>
<form>
<input type=button value="进入符合分辨率的页面" onClick="redirectPage()">
</form>
</center>

posted on 2005-03-27 21:47  小迪  阅读(768)  评论(0编辑  收藏  举报