不知我能否表達清楚。一個search.aspx頁面用來做搜索,別的頁面提交get到search.aspx,search.aspx頁面還可以允許瀏覽者再次搜索,問題是沒有源碼, 不能寫在服務器端,只能通過腳本解決,我是這樣寫的:<script>function noFormGoSearch(){ var t = document.getElementById("SearchItem").value; var v = trim(document.getElementById("Keyword").value); if(v.length > 100){ alert("您輸入的關鍵字過長!"); return false; } if(v == "" || v.substring(0,3) =="請輸入") { alert("請輸入關鍵字!"); return false; } var url = "/search.aspx?t="+t+"&q="+encodeURI(v); window.open(url);}</script><input tabindex="1" type="text" id="Keyword" value="" onfocus="this.value=''" style="width: 200px" /> <select id="SearchItem" name="SearchItem"> <option value="seller">供應信息</option> <option value="buyer">求購信息</option> </select> <input tabindex="2" type="submit" class="searchbtn" value="搜 索" onclick="return noFormGoSearch()" />用起來倒是可以,問題是window.open讓我很不爽,而且瀏覽者要打開一個新的窗口,用戶體驗也不好,怎么樣做才能只在本頁進行搜索呢?
- 2 回答
- 0 關注
- 466 瀏覽
添加回答
舉報
0/150
提交
取消