js 跳转的问题 谢谢啊

来源:百度知道 编辑:UC知道 时间:2024/05/27 14:32:40
<head>
<title>check</title>
<script language= javascript>
function redirectPage(){
var url1280="1.htm";
var url1024="2.htm";
if((screen.with==1280)&&(screen.height ==1024))
window.location.href=url1280 ; //在这一行提示缺少标识符
else ((screen.width ==1024)&&(screen.height ==768))
window.location.href=url1024 ;
}
//!-->
</script>
</head>
<body onload = "redirectPage()">
</body>
</html>
上面是我写的源文件
为什么frontpage总是提示我
window.location.href=url1280 ;
这一行缺少标识符。
帮我看看程序有没有错误,谢谢!
你们再仔细看看程序 我按照你们说的做了
还是不行
看看语法有没有错啊
我刚学js
谢谢

写成这样
<head>
<title>check</title>
<script language= javascript>
function redirectPage(){
if((screen.with==1280)&&(screen.height ==1024))
window.location.href="1.htm" ; //在这一行提示缺少标识符
else ((screen.width ==1024)&&(screen.height ==768))
window.location.href="2.htm" ;
}
//!-->
</script>
</head>
<body onload = "redirectPage()">
</body>
</html>

完整路径,http://

url1280 不要写成变量 ,
window.location.href="1.htm";