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

标签 javascript html beagleboard

我正在 Beagleboard 上使用网络服务器。服务器是用cherrypy制作的,我想创建一个登录页面来对另一个网页进行身份验证。

我正在使用在 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>

但是我收到以下错误: NotFound:(404,“找不到路径'/home/root/webserver/pag.html'。”)

最佳答案

在这段代码中尝试一下,您也可以指定新窗口的高度宽度

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

关于javascript - 如何使用 JavaScript 在网络浏览器中打开另一个窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16827009/

相关文章:

javascript - RequireJS 中的变量依赖

javascript - 将本地化添加到 vue-tables2 表

JavaScript 函数和按钮

html - Mathjax 模板不能在本地计算机上工作

html对象标签边框问题

python - pyserial/Modbus - 故障排除 "No communication with instrument"

linux - 从 64 位机器远程调试 Beaglebone

javascript - 谷歌折线图中的内存泄漏

python - 启动 cron 作业以在 Beagle Bone 上的 venv 中运行 Flask 应用程序

Firefox 和 contentEditable 跨度