簡體   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