-->

Open with target=“_blank”?

2019-08-02 12:17发布

问题:

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 :)



标签: razorpdf