| 实用的检测分辨率的程序代码 |
|
|
|
作者:佚名 文章来源:不详 点击数: 更新时间:2006-12-5 15:48:16  |
上网用户的屏幕分辨率未必都是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>
|
| 文章录入:bolang 责任编辑:bolang |
|
上一篇文章: 怎样使文字旋转 下一篇文章: 【推荐】一个非常漂亮的列表框 |
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |