【发布时间】:2013-07-19 03:07:37
【问题描述】:
我是 JavaScript 新手,我需要在用户单击提交时在新的弹出窗口中打开此功能(以防代码无效)。
代码应该做什么: 用户输入代码,新窗口弹出并开始下载(如果代码正确)或将用户带到无效页面(如果代码无效)。无效页面现在出现在父窗口中,它需要是一个弹出页面并将原始页面留在弹出窗口后面。
我已经在 for 括号中尝试了 target="_blank",但没有成功,我也尝试了 onSubmit="window.open"。
<script>
function process()
{
var url="https://secure.logmeinrescue.com/R?i=2&Code=" + document.getElementById("url").value;
location.href=url;
return false;
}
</script>
<form onSubmit="return process();">
Enter your 6-digit code to start a remote control session:<br> <input type="text" name="url" id="url"> <input type="submit" value="Start Session">
</form>
【问题讨论】:
-
使用
window.open打开一个新窗口 -
感谢 neo 的回复和更正:)。我应该把window.open放在哪里,我在表格括号中尝试了它并作为location.href的替代品,它仍然无法正常工作。
标签: javascript html forms url