为什么“ _Blank”不能使URL在新的浏览器窗口中打开?

问题描述

我已经使用Target =“ _ blank”获得了此代码,该代码应在新标签页中打开“ NavigateURL”:

<div class="row">
    <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl="https://www.amazon.com/Rebel-Cause-Twains- 
        Hidden-Memoirs/dp/107331071X/garrphotgall-20">
        <asp:image runat="server" ImageUrl="Images\RWAC_BothCovers.jpg" 
            style="width:144px;height:120px;margin-left: 60px;" /><br />
        <asp:Label runat="server" Target="_blank"></asp:Label>
    </asp:HyperLink>
</div>

...但是没有;是因为它是从Visual Studio(IIS Express(Google Chrome))运行的网站的“测试”版本?还是在“现实世界”中无法正常工作?如果是这样,我该怎么解决

我不知道为什么需要标签(我从其他地方复制了想法),但是即使我在asp的主要部分中添加 Target =“ _ blank” ,也是如此:超链接(在asp:Label之外)-不管我是否完全取出标签-它的工作原理都一样(它工作不正常,或者是我期望的那样)。

解决方法

问题应该很明显: Target =“ _ blank” 位于错误的元素上。实际上,我根本不需要标签。

将指令放在正确的位置(在asp:HyperLink上):

<div class="row" style="justify-content:center;padding-top: 8px;padding-bottom: 4px;">
    <asp:HyperLink ID="HyperLink10" runat="server" Target="_blank" 
            NavigateUrl="https://www.amazon.com/Adventures-Screen-Trade-William- 
            Goldman-ebook/dp/B007Z7UDF8/garrphotgall-20">
        <asp:image runat="server" 
            ImageUrl="Images\Goldman_AdventuresInTheScreenTrade.jpg" 
            class="img-fluid" style="width:144px;height:144px;border: 2px solid blue;" 
            />
    </asp:HyperLink>
</div>

...使它正常工作-单击图像会打开一个新标签。