2016-11-02 31 views
0

在Web窗體上我有一個asp:按鈕,並將OnClientClick設置爲某個javascript,腳本打開一個新選項卡,然後按鈕後面的代碼執行Response.Redirect,將原始頁面保留在原始選項卡中。打開新選項卡,並將原始選項卡重定向到新頁

我該如何修改這個,以便在原始選項卡上也發生Response.Redirect?按照下面的代碼,IE新標籤隨booking.aspx打開,但原始選項卡CurrentPage.aspx更改爲NewPage.aspx?

腳本:

<script type = "text/javascript"> 

     function SetTarget() { 

      document.forms[0].target = "_blank"; 

     } 

</script> 

按鈕隱藏代碼:

protected void btnGo_Click(object sender, EventArgs e) 
     { 
      Response.Redirect("booking.aspx?id=" + lbBooking.Text + "&flag=exists"); 

     } 
+0

在SetTarget功能,嘗試window.location.href ='YourURL」 – Sami

+0

除了已經有什麼? – DarkW1nter

+0

是的,函數SetTarget(){ document.forms [0] .target =「_blank」; window.location.href ='YourURL'; } – Sami

回答

1

試試這個:

function SetTarget() { 
    document.forms[0].target = "_blank"; 
    window.location.href = 'YourURL'; 
} 
相關問題