繁体   English   中英

使用 javascript 进行谷歌搜索的高级搜索 function 但遇到一些问题

[英]Advance search function of google search using javascript but getting some problems

下面是我试图获取查询字符串值的表单代码。

 <form id="form1"> <label for="allthesewords"> all these words</label> <input type="text" id="allthesewords"> <br> <label for="thisexactwordphrase">this exact word phrase</label> <input type="text" id="thisexactwordphrase"> <br> <label for="anyofthese">any of these</label> <input type="text" id="anyofthese"> <br> <label for="noneofthese">none of these</label> <input type="text" id="noneofthese"> <br> <input type="submit" value="Advance Search" onClick="advanceSearch()"> </form>

这是我正在构建查询字符串的 javascript function 。

 function advanceSearch(){ document.getElementById("form1").action="https://www.google.com/search?as_q="+document.getElementById("allthesewords").value+"&as_epq="+document.getElementById("thisexactwordphrase").value+"&as_oq="+document.getElementById("anyofthese").value+"&as_eq="+document.getElementById("noneofthese").value; return true; }

So, the actual problem is while clicking on the submit button it must redirect to this url https://www.google.com/search?as_q=Harvard%20univeristy%20students&as_epq=students%20of%20Harvard%20Univeristy&as_oq=Harvard&as_eq=almamater However ,当我运行我的代码时,它只是重定向到这个 url: https://www.google.com/webhp

提前致谢!!!!!

 <form action="https://www.google.com/search"> <p>Find page with</p> <input class="input_bar" type="text" name="as_q" placeholder="all these words"> <input class="input_bar" type="text" name="as_epq" placeholder="this exact word or phrase"> <input class="input_bar" type="text" name="as_oq" placeholder="any of these words"> <input class="input_bar" type="text" name="as_eq" placeholder="none of these words"> <input id="btn" type="submit" value="Advance Search"> </form>

用它!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM