繁体   English   中英

Firefox Java脚本形式

[英]Firefox java script form

我下面有以下jsp代码。 我遇到了Firefox在get方法中发送与Interenet Explorer不同的参数的问题。 有任何想法吗?

这是获取网址:

Internet Explorer: http : //www.example.com/app/search/SkillSearch.do?dispatch= skillSearch2& textSearch= test& search=&searchField= test& searchType=

Firefox: http//www.example.com/app/search/SearchPeople.do? dispatch = textSearch = 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)"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <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>&nbsp;&nbsp;&nbsp;&nbsp;
            <input class="button" type="button" value="Search" onclick="doSearch(searchType, searchField)" />
        </html:form>
    </p>
</logic:present>

验证。 验证。 验证。 段落不能包含表单,并且不同的浏览器似乎正以不同的方式从该错误中恢复。

此外,不要假设第一个元素和第一个孩子是相同的。 当您拥有以下内容时,某些浏览器会创建一个完全由空格组成的textNode: <foo> <bar></bar> </foo>

David Dorward的答案是正确的。 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/949 (如果您正在提供古怪模式的文档,这或多或少是您的标记)上比较IE和Firefox

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM