先做好几个页面,比如一个htm1.htm是800*600,一个是htm2.htm是1024*768的
然后在你的入口页面 index.htm 中判断:
然后在你的入口页面 index.htm 中判断:
<html>
<head>
<script language=javascript>
<!--
function mHref() {
if (screen.width == 1024) location.href = "htm2.htm";
else if (screen.width == 800) location.href = "htm1.htm";
else return(false);
}
//-->
</script>
</head>
<body onload="mHref();">
</body>
</html>
此博客展示了一段HTML和JavaScript代码。通过JavaScript的mHref函数,根据屏幕宽度进行判断,若宽度为1024则跳转到htm2.htm,为800则跳转到htm1.htm,否则返回false,在页面加载时调用该函数。
1万+

被折叠的 条评论
为什么被折叠?



