根据用户显示器分辨率自动调用网页显示

2009-02-14 11:42:36 | 【

本脚本自动判断用户的分辨率大小,然后转向相应的网页显示给用户

查看演示页面 View Demo 查看全部代码 View Code

在网页<body>区添加以下代码


<script language="JavaScript">
[CODEBOX]
根据用户显示器分辨率自动调用网页显示

<!--
// Copyright 2001 by www.CodeBelly.com
// Do *not* remove this notice.

// INSTRUCTIONS

// Place this script in the <head> of the page you will use
// for redirection *only*. It should *not* be placed in a
// regular (content) page.

// Set page destinations for the various screen sizes below.
// If the pages are in the same directory as the page with
// this script, only the page filename is needed; otherwise
// use the full, http://www.site.com/page.html address.

// If you have one page used for more than one size (say,
// both 1024 and Larger), then use the same page address
// in each of the associated variables.

pageFor640 = "pageFor640.html";
pageFor800 = "pageFor800.html";
pageFor1024 = "pageFor1024.html";
pageForLarger = "pageForLarger.html";

// Set showAlert to "yes" if you wish an alert box to appear
// when the visitor hits your referer page; otherwise, set
// it to "no"

showAlert = "yes";

// This is the message that will be seen if showAlert is
// used; alter it as needed.

sayOnAlert = "Redirecting to a page designed for your screen size...";

// DO NOT EDIT BELOW THIS LINE.
// ----------------------------

var Wide = screen.width;

if (Wide <= 640){
if (showAlert == "yes"){
alert(sayOnAlert);
}
window.location = pageFor640;
}

else if (Wide <= 800){
if (showAlert == "yes"){
alert(sayOnAlert);
}
window.location = pageFor800;
}

else if (Wide <= 1024){
if (showAlert == "yes"){
alert(sayOnAlert);
}
window.location = pageFor1024;
}

else {
if (showAlert == "yes"){
alert(sayOnAlert);
}
window.location = pageForLarger;
}

//-->
</script>
[/CODEBOX]

下载"根据用户显示器分辨率自动调用网页显示"

  • 本地下载
  • 本地下载2

相关资源