form
单击提交时,我正在尝试打开一个新页面。<form></form>
当标签不存在时,此代码运行良好。为什么?我怎样才能使它与那里的表单标签一起工作?
HTML
<form name="input">
<input id="Answer" name="Answer" value="" placeholder="something"/>
...
<input id="Answer" name="Answer" value="" placeholder="something"/>
<input type="submit" value="Submit" onclick="reload(this)"/>
</form>
JS
function reload(e) {
e.preventDefault();
// do somthing with inputs
window.open('new_page.html', '_self');
// window.location.href = 'new_page.html';
}
我都试过了window.open('new_page.html', '_self');
,window.location.href = 'new_page.html';
还有e.form.preventDefault;