当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 实用的检测分辨率的程序代码

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 实用的检测分辨率的程序代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 468 ::
收藏到网摘: n/a

上网用户的屏幕分辨率未必都是800×600的,有相当一部分人仍然在使用640×480的分辨率上网,试想:你辛辛苦苦作的
页面在别人的浏览器理看到的将面目全非。

这个小程序在用户进入页面的时候会检测它们的分辨率,然后根据分辨率的不同,指向相应的页面。当然,讲究的你应当
事先分别做好800×600和640×480的页面。Try it,really good!

注意:本例没有为不同的分辨率作相应的页面,你可以按下面的按钮看看出现的提示,你只要明白意思就可以了。



以下代码加入<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>