利用javascript返回查詢頁面保持原來的查詢條件和資料

來源:互聯網
上載者:User

直接返回history.back();或者history.go(-1);
  回自動儲存的

C#代碼中返回上級頁面

  this.ClientScript.RegisterStartupScript(GetType(), "alert", "alert('修改成功');history.go(-2)", true);

javascript:history.go()和History.back()的區別

<input type=button value=重新整理 onclick="window.location.reload()">
<input type=button value=前進 onclick="window.history.go(1)">
<input type=button value=後退 onclick="window.history.go(-1)">
<input type=button value=前進 onclick="window.history.forward()">
<input
type=button value=後退 onclick="window.history.back()"> 後退+重新整理<input
type=button value=後退
onclick="window.history.go(-1);window.location.reload()">在C#
Web程式中,如為頁面按鈕寫返回上一頁代碼

this.RegisterClientScriptBlock("E", "<script language=javascript>history.go(-2);</script>");

其中,history.go(-2),要寫為-2,因在按鈕事件觸發前,已重新整理一次頁面,所以應是-2。

Response.Write("<script language=javascript>history.go(-2);</script>");

此處也要寫為“-2”。跟直接寫指令碼的有所不同。history.back()是會上一頁
i=1
history.go(i)去指定的某頁
如果是history.go(0)那就是重新整理這兩個屬於JS代碼,相當於IE的前進、後退功能。
具體的用處就要看什麼時候需要這個就用上。比如使用者註冊時的驗證是後台驗證,不符合要求的時候就可以用這個,可以最大限度保證使用者少重複輸入資料。
例如:載入頁面:
   function onLoadPage(){
     if(event.srcElement.tagName=="SPAN"){
         oFrame=top.window.middle.frames[2];
         oTxt=event.srcElement.innerText;
         switch(oTxt){
             case "前 進":
                 oFrame.history.go(1);
             case "後 退":
                 oFrame.history.back();
             case "刷 新":
                 oFrame.location.reload();
         }
     }
}

開啟一個jsp頁面,肯定是用用戶端指令碼進行重新整理了。
Javascript重新整理頁面的幾種方法:
1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.