当我点击提交单词时,链接出现错误
<form id="searchf" target="_blank" method="get" action="http://www.example.com/aa/bb/#/">
<input type="text" placeholder="free" name="url">
<input type="submit" value="send" />
</form>
最佳答案
您可以使用window.location.replace
进行重定向。喜欢:
$('#searchf').submit(function(e){
e.preventDefault();
window.location.replace( $(this).attr('action') + $('[name="url"]').val() );
});
这是一个 fiddle :
$(function() {
$('#searchf').submit(function(e){
e.preventDefault();
window.location.replace( $(this).attr('action') + $('[name="url"]').val() );
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="searchf" target="_blank" method="get" action="http://www.example.com/aa/bb/#/">
<input type="text" placeholder="free" name="url">
<input type="submit" value="send" />
</form>
关于javascript - 如何从 get 中删除这个 ?url=,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49752765/