Open <anchor> with target=“_blank”?

微笑、不失礼 提交于 2019-12-11 05:29:32

问题


I am using RazorPdf to generate a .pdf document from one of my controller actions. All works well, except that in my generated .pdf, I have an embedded anchor that opens yet another .pdf, that resides on the web site.

Currently, if the user clicks the anchor, the referenced .pdf opens in the same browser window. I don't want this behavior. I want anchor to open in a new browser tab (e.g. target="_blank"), but can't see any way to accomplish this. Here's my anchor in my view:

<!-- Note: target="_blank" does not work //-->
<anchor target="_blank" font="underline" name="top" reference="http://www.example.com/Downloads/Attachment.pdf">Click Here</anchor>

回答1:


You could add some jquery function and call it on the click of the anchor tag

jquery function something like

$("#OpenAttachment").click(function (e) {

        var actionUrl = '/Downloads/Attachment.pdf';
        window.open(actionUrl, '', 'width=1000,height=800');
    });

This will open a new browser window. Hope this helps :)



来源:https://stackoverflow.com/questions/17051773/open-anchor-with-target-blank

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!