我有一个提交 url 操作的表单。但是,我不希望它在提交时打开一个包含 url 的新窗口。我应该如何避免这种情况?
<form name="leds" id="ledSend" method="get" target="_blank" action="https://agent.electricimp.com/Fk43xPMkSrWF">
Lamp Control: <input type="radio" name="led" value="0" checked>Off
<input type="radio" name="led" value="1">On<br>
How long should the Lights stay on? <input type="text" name="timer" value="10">seconds<br>
Your name? For Our Records <input id="name" type="text" name="user" placeholder="Your name here"> <br>
<input type="submit" value="Update!" onclick="alert(theInput.value)"/>
<script>
var theInput = document.getElementById("name");
我不希望此表单将窗口更改为
https://agent.electricinp.com
提交时。我如何避免这种情况,以便用户留在提交表单的原始页面上。
最佳答案
摆脱target="_blank"
<form name="leds" id="ledSend" method="get" action="">
关于javascript - 如何使表单在提交 url 操作时不打开新窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27116748/