简体   繁体   English

模拟鼠标中键单击超链接

[英]Simulate Middle Mouse Click on hyperlink

Is there any way to simulate a middle mouse click on a hyperlink? 有什么方法可以模拟鼠标中键单击超链接吗? I have the following code, for showing a list of succeeded imports of products: 我有以下代码,用于显示成功导入产品的列表:

<tr>
   <td>
    @{
       int counter = 0;
       foreach (int productid in Model.SucceededProductIdsList)
       {
         <ul>
         <li>-------------------------------------------------------</li>
         <li><b>@String.Format("ProductID: {0}", Convert.ToString(productid))</b></li>
         <li><b>@String.Format("{0}", Model.SucceededProductManufacturerIdsList[counter])</b></li>
         <li><b><a href="http://www.MyWebshop.com/Admin/Product/Edit/@productid" target="_blank">Show Product</a></b></li>
         </ul>
         counter++;
       }
     }
 </td>

Above code gives the admin of the web shop a list of all products that succeeded to import. 上面的代码为网上商店的管理员提供了成功导入的所有产品的列表。 I added in a hyperlink to the imported product, so it's easier for the user to directly find and if needed edit the product. 我在导入的产品中添加了超链接,因此用户可以更轻松地直接找到该产品,并在需要时对其进行编辑。

Next code shows the link to a product: 下一条代码显示了产品链接:

<li><b><a href="http://www.MyWebshop.com/Admin/Product/Edit/@productid" target="_blank">Show Product</a></b></li>

Question

I used target="_blank" , so the page opens in a new tab, however the current tab of the user, changes to the new tab. 我使用了target="_blank" ,因此页面在新选项卡中打开,但是用户的当前选项卡更改为新选项卡。 That is not what I want. 不是我想要的。 I want the page to open in a new tab, but the users current tab should still be the same and not the new tab.(Same behavior as when a user clicks on the link with the Middle Mouse Button) 我希望页面在新选项卡中打开,但用户的当前选项卡应该仍然相同,而不是新选项卡。(与用户单击鼠标中键的链接时的行为相同)

Is there any HTML or C#/Razor allowing me to do that? 有没有HTML或C#/ Razor允许我这样做? If so, how? 如果是这样,怎么办?

I am afraid there is nothing you can do. 恐怕您无能为力。 This behaviour depends purely on browser. 此行为完全取决于浏览器。 In some browsers (firefox for instance) you can configure that behaviour. 在某些浏览器(例如Firefox)中,您可以配置该行为。 Tab is browser being, and you don't have any reliable method to control active tab from web page level. 标签是浏览器,您没有任何可靠的方法可以从网页级别控制活动标签。

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

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