我在下面有以下jsp代码。我遇到的问题是Firefox在get方法中发送的不同参数比Interenet Explorer更多。有什么想法吗?
以下是获取网址:
Internet Explorer: http://www.example.com/app/search/SkillSearch.do?dispatch=skillSearch2&textSearch=test&search=&searchField=test&searchType=
<script>
function doSearch(selection,searchInfo){
// Get the Search Bar Form
var searchForm = document.getElementById('searchBarForm').firstChild;
// Get the dispatch input in the Search Bar Form
var searchFormChildren = searchForm.childNodes;
var dispatch;
for (var i=0; i<searchFormChildren.length; i++) {
if (searchFormChildren[i].name == "dispatch") {
dispatch = searchFormChildren[i];
break;
}
}
// Variable to hold search input
var searchField;
// Set form variables depending on type of search selected
if (selection.selectedIndex == "0") {
dispatch.value = "skillSearch2";
searchForm.action = "/app/search/SkillSearch.do";
for (var i=0; i<searchFormChildren.length; i++) {
if (searchFormChildren[i].name == 'textSearch') {
searchField = searchFormChildren[i];
break;
}
}
}
else if (selection.selectedIndex == "1") {
dispatch.value = "searchPeople";
searchForm.action = '/app/search/SearchPeople.do';
for (var i=0; i<searchFormChildren.length; i++) {
if (searchFormChildren[i].name == 'search') {
searchField = searchFormChildren[i];
break;
}
}
}
else if (selection.selectedIndex == "2") {
dispatch.value="search";
searchForm.action = '/app/search/LinkSearch.do';
for (var i=0; i<searchFormChildren.length; i++) {
if (searchFormChildren[i].name == 'search') {
searchField = searchFormChildren[i];
break;
}
}
}
searchField.value = searchInfo.value;
searchForm.submit();
}
function checkKeyPress(selection, searchInfo) {
if (window.event && window.event.keyCode == 13) {
doSearch(selection, searchInfo);
}
}
</script>
<logic:present name="SSO_TOKEN" scope="session">
<p id="searchBarForm">
<html:form action="/search/SearchPeople.do" method="get">
<input type="hidden" name="dispatch" value=""/>
<input type="hidden" name="textSearch" value="" /> <input type="hidden" name="search" value="" />
<input size="15" name="searchField" value="Search" onfocus="if (this.value == 'Search') this.value = '';" onkeypress="checkKeyPress(searchType, searchField)"/>
<select class="select" name="searchType" size="1" style="font-size: 13px;" onkeypress="checkKeyPress(searchType, searchField)">
<option value="" selected>Subject Matter Experts</option>
<option value="">Users</option>
</select>
<input class="button" type="button" value="Search" onclick="doSearch(searchType, searchField)" />
</html:form>
</p>
</logic:present>
答案 0 :(得分:3)
Validate. Validate. Validate.段落不能包含表单,不同的浏览器似乎会以不同的方式从该错误中恢复。
此外,不要假设第一个元素和第一个子是相同的。有些浏览器会创建一个完全由空格组成的textNode:<foo> <bar></bar> </foo>
。
答案 1 :(得分:1)