[ js ] 關於location.href奇怪的問題
我要做出輸入正確密碼按下送出之後,會用"location.href";將頁面轉到新的頁面。
但是下面這段code只有在IE能展現出完整功能,在Chrom、Firefox都只做到驗證
密碼而已,沒辦法跳頁;我試過改用window.location.href、loaction....可是都
不行,請問要怎麼改呢?
※ 一樣是用"loaction.href",在第二個code就可以在各個瀏覽器使用,實在想不
出為什麼,拜託大家幫我解答!!
**************** code1 **************
<html>
<head>
<script language="javascript">
function password(pwd){
alert("function開始");
if (pwd=="123")
{
alert('Welcome!');
location.href="http://www.yahoo.com.tw";
}else{
alert("Denied!");
}
}
</script>
</head>
<body>
<form name='myform' onsubmit="password(myform.input.value)">
<input type="text" name="input" rows="1" size="20"/>
<input type="submit" name="submit" value="送出"/>
</form>
</body>
</html>
************* 第二支code *************************
<script language="javascript">
var password = prompt("請輸入密碼","")
if (password=="123")
{
alert('Welcome! 一起聽首有深度的歌曲~!')
location.href='http://www.youtube.com/watch?v=UqD8OD0a-xU&feature=related'
}else{
if (password==null) { //null不可以為字串!!
alert('幹嘛按取消?想逃?!');
location.href="./用prompt遮蓋原始碼.html";
}else if(password==""){
alert('..妳沒輸入任何東西');
location.href="./用prompt遮蓋原始碼.html";
}else if (password!="123") {
alert('密碼錯了!!!請再輸入一次密碼');
location.href="./用prompt遮蓋原始碼.html";
}
}
</script>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.253.0.119
→
08/28 15:07, , 1F
08/28 15:07, 1F
→
08/28 15:13, , 2F
08/28 15:13, 2F
推
08/28 15:19, , 3F
08/28 15:19, 3F
推
08/28 15:29, , 4F
08/28 15:29, 4F
→
08/28 15:29, , 5F
08/28 15:29, 5F
→
08/28 15:30, , 6F
08/28 15:30, 6F
→
08/28 18:38, , 7F
08/28 18:38, 7F
→
08/28 18:39, , 8F
08/28 18:39, 8F
→
08/28 19:36, , 9F
08/28 19:36, 9F
→
08/28 21:41, , 10F
08/28 21:41, 10F