简体   繁体   English

如何在新选项卡/窗口中打开 ASP 页面?

[英]How to open ASP page in a new tab/window?

I know that the HTML anchor tag has an attribute called target , which will open a new page in a new window/tab if we set target='_blank' .我知道 HTML 锚标记有一个名为target的属性,如果我们设置target='_blank' ,它将在新窗口/选项卡中打开一个新页面。 It should work well with static HTML pages.它应该适用于 static HTML 页面。

However, when we submitting a form by clicking the submit button on an ASP page, I find that the result page normally will be loaded into the same tab/window.但是,当我们通过单击ASP页面上的提交按钮提交表单时,我发现结果页面通常会加载到同一个选项卡/窗口中。

So my question is: are we able to load page into a new tab/window when user clicks submit button?所以我的问题是:当用户单击提交按钮时,我们是否能够将页面加载到新的选项卡/窗口中?

Thanks.谢谢。

EDIT: Looks like <form target='blank'> is the answer although its said to be deprecated according to w3schools website.编辑:看起来<form target='blank'>是答案,尽管根据 w3schools 网站说它已被弃用。 :) :)

Just like a link:就像一个链接:

<form target='_blank'>

No need to do anything on the ASP side of things.无需在 ASP 方面做任何事情。 Of course, as with all pop-ups, this is subject to browser settings.当然,与所有弹出窗口一样,这取决于浏览器设置。

Form's target shold work.表单的目标工作。

<form target="_blank" ...></form>

From here (have you searched?)这里(你搜索过吗?)

You have two methods for redirecting the page to new tab in asp您有两种方法可以将页面重定向到asp中的新选项卡

1) Make an onclientclick event of Button and on code behind of Button Click write the following code:- 1) 制作 Button 的 onclientclick 事件,并在 Button Click 后面的代码上编写以下代码:-

button.OnClientClick = "aspnetForm.target='_blank'"; Response.Redirect("yourpage.aspx");

2)You can also use javascript 2)您也可以使用javascript

 button.Attributes.Add("onclick", "window.open('yourpage.aspx');return false;");

Both the method will redirect your page to new tab on clicking the button.这两种方法都会在单击按钮时将您的页面重定向到新选项卡。

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

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