我想创建一个从我的网站中搜索其他网站的搜索,问题是其他网站正在使用-而不是+,例如:https://somewebsite.com/?search=example-search-query
但是当我使用此代码时:
<form class="example" method="get" action="https://europixhd.io/svop2/zznewsrv4" style="margin:auto;max-width:300px">
<input type="text" placeholder="Movie Name Here..." name="search">
<button type="submit"><i class="fa fa-play"></i></button>
</form>
它当然添加了+而不是-任何帮助将不胜感激,谢谢!
使用绑定到提交动作的函数
<html>
<form class="example" method="get" action="" id="formID" style="margin:auto;max-width:300px">
<input type="text" placeholder="Movie Name Here..." name="search" id="search">
<button type="submit" ><i class="fa fa-play"></i></button>
</form>
</html>
<script>
var form = document.querySelector('#formID');
form.addEventListener('submit', searchUpdater);
function searchUpdater() {
var text = document.getElementById("search").value.replace(" ", "-");
document.getElementById("search").value = text;
return true;
}
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句