作者shuanyin (shuanyin)
看板Ajax
標題[問題] Javascript 裡開網頁
時間Tue Jun 12 00:43:13 2007
大家好~
我想請問要怎麼在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
1F:推 squalll:開新視窗嗎? window.open 06/12 10:08
2F:推 squalll:如果是在本來的網頁就用 window.location 06/12 10:14
3F:推 shuanyin:window.location(網址) 請問是這樣嘛? 06/12 12:27
4F:→ shuanyin:我試了一下 好像不是 06/12 12:28
5F:推 ephesians:window.location = '網址字串' 06/12 15:26
6F:推 shuanyin:謝謝你們! 我成功了~ 06/12 20:02
7F:推 shuanyin:那如果要開啟同一資料夾下的另一個自己做的網頁呢? 06/12 20:12
8F:推 ephesians:直接指定另一個網頁的相對位址,同目錄只要指定檔名就好 06/12 21:31
9F:推 shuanyin:那如果我將整個資料夾移到別台電腦 是不是就不行了呢? 06/12 21:43
10F:→ shuanyin:也是用 window.location='相對位置' 這個指令嘛? 06/12 21:45
11F:推 ephesians:不對,寫絕對位址才會發生你講的問題 06/13 00:00
12F:推 shuanyin:謝謝! 我成功了~ 06/13 00:17
13F:推 ephesians:Congratulations! 06/13 22:40