简体   繁体   English

如何使用JavaScript在网络浏览器中打开另一个窗口?

[英]How do I use JavaScript to open another window in the web browser?

I'm working with a webserver on the Beagleboard. 我正在Beagleboard上使用Web服务器。 The server was made in cherrypy and I want to create a login page to authenticate to another webpage. 该服务器采用cherrypy制成,我想创建一个登录页面以对另一个网页进行身份验证。

I am using the following HTML/JavasScript code that I found on the Internet: 我正在使用以下在Internet上找到的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>

But I receive the following error: NotFound: (404, "The path '/home/root/webserver/pag.html' was not found.") 但是我收到以下错误: NotFound: (404, "The path '/home/root/webserver/pag.html' was not found.")

在此代码中尝试此操作,您还可以指定新窗口的高度宽度

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM