2013-05-30 91 views
1

我正在使用Beagleboard上的網絡服務器。服務器是用cherrypy製作的,我想創建一個登錄頁面來認證另一個網頁。如何使用JavaScript在Web瀏覽器中打開另一個窗口?

我使用下面的HTML /使用JavasScript代碼,我在網上查到:

<html> 
<head> 
<title> 
Login page 
</title> 
</head> 
<body> 
<h1 style="font-family:Comic Sans Ms;text-align="center";font-size:20pt; 
color:#00FF00;> 
Simple Login Page 
</h1> 
<form name="login"> 
Username<input type="text" name="userid"/> 
Password<input type="password" name="pswrd"/> 
<input type="button" onclick="check(this.form)" value="Login"/> 
<input type="reset" value="Cancel"/> 
</form> 
<script language="javascript"> 
function check(form)/*function to check userid & password*/ 
{ 
/*the following code checkes whether the entered userid and password are matching*/ 
if(form.userid.value == "myuserid" && form.pswrd.value == "mypswrd") 
{ 
window.open('pag.html')/*opens the target page while Id & password matches*/ 
} 
else 
{ 
alert("Error Password or Username")/*displays error message*/ 
} 
} 
</script> 
</body> 
</html> 

但我收到以下錯誤: NotFound: (404, "The path '/home/root/webserver/pag.html' was not found.")

+0

也許是因爲它是page.html什麼的? – doppelgreener

+2

文件'/ home/root/webserver/pag.html'是否存在? – Isaac

回答

1

試試這個在此代碼,你可以指定高度寬度新視窗也

<INPUT type="button" value="New Window!" onClick="window.open('http://www.pageresource.com/jscript/jex5.htm','mywindow','width=400,height=200')"> 
相關問題