我尝试将表单提交到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>
答案 0 :(得分:0)
您需要在提交时return false
以阻止页面刷新。
onClick="document.getElementById('SearchForm').submit() return false;"