看板 Ajax 關於我們 聯絡資訊
大家好~ 我想請問要怎麼在javascript裡開啟一個網頁呢?指令是什麼? 我現在讓使用者輸入month跟day submit後會去跑function 在function 裡判別式如果true 則要開啟網頁 <-------我的問題所在 程式碼如下 <html> <head> <title>星座</title> <script type="text/javascript"> function show(month,day) { document.writeln("p"); if(month==01) { if(day>=20) 想要開啟某網頁 可是我不曉得該用什麼指令 讓畫面跳到那網頁 else document.writeln("wrong"); } } </script> </head> <body> <form name="calender" action="javascript:show()"> <h1>請輸入生日</h1> <p> Please enter the month (mm): <input type=text name=month maxlength="2"><br/> Please enter the day (dd): <input type=text name=day maxlength="2"><br/> <input type=submit name=submit1 onclick=show(month.value,day.value)> </p> </form> </body> </html> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 125.225.173.15
squalll:開新視窗嗎? window.open 06/12 10:08
squalll:如果是在本來的網頁就用 window.location 06/12 10:14
shuanyin:window.location(網址) 請問是這樣嘛? 06/12 12:27
shuanyin:我試了一下 好像不是 06/12 12:28
ephesians:window.location = '網址字串' 06/12 15:26
shuanyin:謝謝你們! 我成功了~ 06/12 20:02
shuanyin:那如果要開啟同一資料夾下的另一個自己做的網頁呢? 06/12 20:12
ephesians:直接指定另一個網頁的相對位址,同目錄只要指定檔名就好 06/12 21:31
shuanyin:那如果我將整個資料夾移到別台電腦 是不是就不行了呢? 06/12 21:43
shuanyin:也是用 window.location='相對位置' 這個指令嘛? 06/12 21:45
ephesians:不對,寫絕對位址才會發生你講的問題 06/13 00:00
shuanyin:謝謝! 我成功了~ 06/13 00:17
ephesians:Congratulations! 06/13 22:40