将搜索表单提交到其iframe的另一个页面

时间:2013-03-20 17:19:39

标签: forms iframe form-submit

将提交搜索表单提交到页面A 以将搜索表单转发到页面B 到其iframe并加载页面B 时是否可能在iframe中搜索结果?

实际上,如果我在 Page A 上进行搜索,则会加载包含结果的iframe页面,但我需要在iframe中加载 Page B 并显示结果。

以下是测试页面A http://mysite.com/lidl/page1.html和Page B http://mysite.com/lidl/page2.html

Page#1搜索表单:

<form id="SearchForm" action="http://mysite.com/search-results-jobs/" target="" method="post">
    <input type="hidden" name="action" value="search" />
    <input type="hidden" name="listing_type[equal]" value="Job" />
    <label>
        <strong>What?</strong> 
        <em><input type="text" value="job title, keywords or company name" onblur="if(this.value=='') this.value='job title, keywords or company name'" onFocus="if(this.value =='job title, keywords or company name' ) this.value=''" name="keywords [all_words]" /></em>
    </label>
    <label>
        <strong class="color">Where?</strong>
        <b><input type="text" value="city, state or zip code"  onblur="if(this.value=='') this.value='city, state or zip code'" onFocus="if(this.value =='city, state or zip code' ) this.value=''" name="City[all_words]" /></b>
    </label>
    <a href="#" class="SearchForm-link" onclick="document.getElementById('SearchForm').submit()"/>Search</a>
</form>

第2页

<form id="SearchForm" action="http://mysite.com/search-results-jobs/" target="my-iframe" method="post">
    <input type="hidden" name="action" value="search" />
    <input type="hidden" name="listing_type[equal]" value="Job" />
    <label>
        <strong>What?</strong>
        <em><input type="text" value="job title, keywords or company name" onblur="if(this.value=='') this.value='job title, keywords or company name'" onFocus="if(this.value =='job title, keywords or company name' ) this.value=''" name="keywords[all_words]" /></em></label>
    <label>
        <strong class="color">Where?</strong>
        <b><input type="text" value="city, state or zip code" onblur="if(this.value=='') this.value='city, state or zip code'" onFocus="if(this.value =='city, state or zip code' ) this.value=''" name="City[all_words]" /></b>
    </label>
    <a href="#" class="SearchForm-link" onclick="one(); two(); three(); four();">Search</a>
    <input type="submit" id="btn-search" class="button" value="Cauta"/>
</form>
<iframe id="my-iframe" name="my-iframe" align="right" src="http://mysite.com" frameborder="0" height="100%" scrolling="no" width="100%"></iframe>

1 个答案:

答案 0 :(得分:0)

搜索引擎使用的常用技术是在网址中传递查询。以下是Monster(在加利福尼亚州圣地亚哥搜索JavaScript)的示例:

http://jobsearch.monster.com/search/?q=JavaScript&where=San-Diego__2C-CA

谷歌也是这样的,等等。

您可以将此应用于您自己的网页,以便轻松地将查询从A传递给B.

另一个好处是人们可以通过电子邮件发送查询结果。