問題描述
如何在特定情況下處理 iframe。如何處理 iframe 內容? (How to handle iframe in particular situation. How to handle iframe contents?)
我創建了與通常的搜索引擎相同的搜索框,並且我使用了 iframe 並為該框架提供了谷歌地址。我想通過僅在上框中輸入來搜索谷歌的方法。或者這樣一種方法,即使我直接在 iframe 中搜索谷歌,搜索詞也應該出現在上框。
參考解法
方法 1:
Look like you are trying to do Cross Site scripting using iframe. The method you choose is not supported by almost all modern browser.
Instead if you want to implement google search in your website, to search content within your site. I'll recommend following code
<form action="http://www.google.com/search">
<h5>Search</h5>
<input name="q" type="text">
<input type="hidden" name="sitesearch" value="stackoverflow.com">
<input type="submit" class="btn" value="Go" />
</form>
The above code on search take user to google but search result show only within stackoverflow.com (you can change this with your website address) and on clicking any search result user will come back to your site.
(by shubhamchava、Neha Jain)