MozTW 討論區 https://forum.moztw.org/ |
|
Js語法問題 https://forum.moztw.org/viewtopic.php?f=13&t=17856 |
第 1 頁 (共 1 頁) |
發表人: | lkk6015 [ 2007-03-05, 18:24 ] |
文章主題 : | Js語法問題 |
請問一下大大 <script type="text/javascript"> <!-- var password = prompt('請輸入密碼:',''); if (password != null) location.href= password + '.html'; else{location.href= '../';} //--> </script> 在 if (password != null) location.href= password + '.html'; else{location.href= '../';} 我不想要連到哪頁就是留在原頁 但輸入錯誤了救回上一頁 |
發表人: | legnaleurc [ 2007-03-05, 18:31 ] |
文章主題 : | |
lkk6015 寫: 請問一下大大
<script type="text/javascript"> <!-- var password = prompt('請輸入密碼:',''); if (password != null) location.href= password + '.html'; else{location.href= '../';} //--> </script> 在 if (password != null) location.href= password + '.html'; else{location.href= '../';} 我不想要連到哪頁就是留在原頁 但輸入錯誤了救回上一頁 代碼: if ( check(password) )
location.reload(); else history.back(); 這樣? function check(password) 是我假設的驗證函式 不知道是不是你說的意思 其實不要動到location就會留在原頁了 要怎麼做要看密碼對頁面的處理 用history.go(0)和history.go(-1)也可以 |
第 1 頁 (共 1 頁) | 所有顯示的時間為 UTC + 8 小時 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |