简体   繁体   English

使用JavaScript在“新建”选项卡中打开其他ASPX页面

[英]Open a different ASPX page in a NEW tab with JavaScript

I have a folder that contains two aspx empty website files (task1.aspx , task2.aspx). 我有一个包含两个aspx空网站文件(task1.aspx,task2.aspx)的文件夹。 That's the code that I have in task1.aspx : 那就是task1.aspx中的代码:

 <html> <head> <title>TASK 1</title> </head> <body> <p id="answer" style="font-size: 89px"></p> <script type="text/javascript"> num1 = parseInt(prompt("Please enter num1:")); num2 = parseInt(prompt("Please enter num2:")); if (num1 > num2) { var ans = num1; document.getElementById("answer").innerHTML = "The biggest number is num1 and is equal to " + ans; } else if (num2 > num1) { var ans = num2; document.getElementById("answer").innerHTML = "The biggest number is num2 and is equal to " + ans; } </script> </body> </html> 

Pretty simple JS code... I just wanted to know if it's possible to open the second aspx file (task2.aspx) right after the JavaScript code of task1 ends so it will open taks2 page in a new, blank page? 非常简单的JS代码...我只是想知道是否有可能在task1的JavaScript代码结束后立即打开第二个aspx文件(task2.aspx),以便它将在新的空白页面中打开taks2页面? Can U help me? 你能帮我吗?


I tried some of the answers here but I actually wanted the new page to be opened in a new tab . 我在这里尝试了一些答案,但实际上我希望在新标签页中打开新页面。 Do you know how to do it? 你知道怎么做吗?

You would want to use the window.open JavaScript with the _blank parameter. 您可能要使用带有_blank参数的window.open JavaScript。

The problem with what you are trying to do is user-experience. 您尝试做的问题是用户体验。 You do not want the user to get disorientated by showing a new page before they see the results of the first. 您不希望用户在看到第一页的结果之前就显示新页面而迷失方向。

Depending on what you are trying to do/code, I would suggest a "next" button on task1 to let the user know they can now go to the "next" page. 根据您要执行的操作/代码,我建议在task1上使用“下一步”按钮,让用户知道他们现在可以转到“下一步”页面。 If this opens up a new window, all is good. 如果这打开了一个新窗口,那一切都很好。 Just my opinion though 虽然只是我的意见

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

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