简体   繁体   English

打开新标签页,还将原始标签页重定向到新页面

[英]Open new tab and also redirect original tab to new page

On a web form I have an asp:button with the OnClientClick set to some javascript, the script opens a new tab then the code behind the button does a Response.Redirect, leaving the original page open in the original tab. 在一个Web表单上,我有一个asp:button,其OnClientClick设置为一些javascript,脚本打开了一个新标签,然后按钮后面的代码执行Response.Redirect,使原始页面在原始标签中保持打开状态。

How can I amend this so that a Response.Redirect also happens on the original tab also? 我该如何修改,以便Response.Redirect也出现在原始选项卡上? IE new tab opens with booking.aspx as per code below, but original tab CurrentPage.aspx changes to NewPage.aspx? IE的新选项卡将按以下代码打开,其中包含booking.aspx,但原始选项卡CurrentPage.aspx更改为NewPage.aspx?

script: 脚本:

<script type = "text/javascript">

        function SetTarget() {

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

        }

</script>

button code-behind: 按钮背后的代码:

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

        }

Try this: 尝试这个:

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

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

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