集合的关系ppt:谁能帮我修改一下代码阿?

来源:百度文库 编辑:中科新闻网 时间:2024/05/14 04:47:12
<script LANGUAGE="JavaScript">
<!-- Begin
function redirectPage() {
var url640x480 = "http://www.163.com/";
var url800x600 = "http://www.toto369.net/";
var url1024x768 = "http://www.sina.com/";
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>

<form>
<input type=button value="进入符合分辨率的页面" onClick="redirectPage()">
</form>

这是一段根据分辨率选择网页的代码,但是需要按钮激活,请那位高手把它改成自动运行的,在此我先谢谢了。

function window.onload() {
var url640x480 = "http://www.163.com/";
var url800x600 = "http://www.toto369.net/";
var url1024x768 = "http://www.sina.com/";
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;
}
或者body里加onload="redirectPage()"

也就是网页加载完毕就运行redirectPage()这个函数!
在此加上<body onload="redirectPage()"></body>就可以了