1

我尝试向 iFrame 提交表单并在 iFrame 中获取搜索结果。无论我写什么文本并推送搜索,它都会刷新父页面和子页面。

我有这个父页面代码:

<form id="SearchForm" <form action="http://itmjobs.ro/" target="my-iframe" method="post">
        <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=''" /></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=''" /></b></label>
        <a href="#" class="SearchForm-link" onClick="document.getElementById('SearchForm').submit()">Search</a>
<div class="wrapper">
    <td><iframe id="my-iframe" iframe name="my-iframe" iframe allowtransparency="yes" align="right" src="http://itmjobs.ro/" frameborder="0" height="1000" scrolling="no" width="1200"></iframe>

这是我需要提交文本的 iframe 代码中的字段:

<div class="quickSearchInputField">Cuvinte cheie<br/>   <input type="text" value="" class="searchText" name="keywords[all_words]"  id="keywords" />
<div class="quickSearchInputName">Oras<br/><input type="text" name="City[like]"  id="City" class="searchStringLike" value=""  />
<div class="quickSearchInputName"><br/><input type="submit" id="btn-search" class="button" value="Cauta"/></div>
4

1 回答 1

0

您需要return false在提交时防止页面刷新。

onClick="document.getElementById('SearchForm').submit() return false;"
于 2013-11-12T02:19:26.780 回答