<!-- Begin
function redirectPage() {
var w=screen.width
var h=screen.height
alert("经系统检测,你的屏幕分辨率为 " + w+"*"+ h )
}
// End -->
</script>
用screen.width可以判断屏幕分辨率的宽度,用screen.height可以判断屏幕分辨率的高度!if (screen.width >= 1440){
//这里执行事件1
}else if (screen.width >= 1366){
//这里执行事件2
}else if (screen.width >= 800){
//这里执行事件3
}else {
//这里执行事件4
}
一个简单的demo示例,如下:
<?phperror_reporting(E_ERROR)
// 分辨率の宽高
$script = '<script language="javascript">'
$script .= 'var screen_width = window.screen.width'
$script .= 'document.cookie = "sw = "+screen_width+""'
$script .= 'var screen_height = window.screen.height'
$script .= 'document.cookie = "sh = "+screen_height+""'
$script .= '</script>'
$width = $_COOKIE['sw']
$height = $_COOKIE['sh']
echo "浏览器分辨率为:".$width."*".$height
echo "<br />"
if($width < 500){
echo 'a'
}else if($width >= 500 && $width < 1000){
echo 'b'
}else if($width > 1000){
echo 'c'
}else{
echo "<pre>"
print_r('数值不在所需范围内!')
exit()
}
?>
可复制粘贴测试一下,若有任何疑问,欢迎追问...