Open <anchor> with target="_blank"? - razorpdf

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>

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

Related

Trigger file download without the anchor element

When using the anchor tags download attribute, the user must click on the link for the file to download. How do trigger a file download without the anchor tag? I tried using the JavaScript download() function, but it did not work.
You can click the button via for eg.
Download
In Jquery
<script type="text/javascript">
$(document).ready(function() {
$('a#someid').attr({target: '_blank',
href : 'http://localhost/directory/file.pdf'}).click();
});
</script>

Trigger click on link on jquery mobile not working

I tried triggering a link via .trigger() function but is not working
<a data-role="button" id="redirectprofile_btn" href="profile.html" rel="external" style="display:block;">Profile</a>
Once i click the link manually, it will display the profile page (profile.html, with its own css and js) but if i use
$("#redirectprofile_btn").click() or $("#redirectprofile_btn").trigger('click'),
it wont redirect.
Im new to jquerymobile, any help would really be great.
Thanks
Use event.prevent default() followed by event.stopImmediatePropogation then changePage to the links href attr value.

Generate Pinterest Share Button That Specifies URL

I am trying to create a "pinterest share" button, but am running into a snag.
Currently, I have the pinterest button (generated from their Widget Builder) appearing in a Lightbox. (For certain reasons, it must appear this way.)
The issue is the Lightbox code has direct linking on it, so the code for the lightbox window is something like: www.domain.com/#/social/4
Pinterest is picking up that URL (which has no images since it's just the lightbox) instead of the URL for the main page (www.domain.com).
Does anyone know how I can specify the exact URL to share via the pinterest button?
I have read some posts that said doing this would work:
<img src="//assets.pinterest.com/images/PinExt.png" alt="Pin it" / > <script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>
However, specifying the URL does not seem to work at all. It appears to be totally ignored and has no impact.
Any ideas?
Thanks in advance!
You can use a standard link and specify all the data in the parameters:
<a href="http://www.pinterest.com/pin/create/button/
?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F
&media=http%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg
&description=Next%20stop%3A%20Pinterest"
data-pin-do="buttonPin"
data-pin-config="above">
<img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" />
</a>
Source: http://developers.pinterest.com/pin_it/
You can try using structured meta data and Rich Pins.

Href issue with pdf

I have following piece of code.
<a id="hlink" href="~/Documents/ABCD.pdf" target="_blank">Document </a>
The pdf doesnot open on Document click. If I copy paste same path into new browser window, the document opens.
And the document opens on click of "Document" hyperlink as well.
"http://localhost/...(the rest of path)" as generated on click of hyperlink.
Is that something I have not added in href hence not allowing it to open on first go?
May be some security settings ?
~ Works for links resolved on the server, if you want that to resolve you need to do
<a id="hlink" href="~/Documents/ABCD.pdf" target="_blank" runat="server">Document </a>

Opening Spring jsp in a popup window

My application needs a solution like Outlook mail: opening an other page as popup window on the parent window. The application is Spring 3 based and uses jsps. How do I make a popup out of my application page in order to make it work as intended at least in most common browsers?
I've tried target and window.open, without getting them work properly in Firefox.
Just as an example, the Spring travel sample app contains a jsp which is launched via a pop-up.
<a id="changeSearchLink" href="hotels/search?searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}">Change Search</a>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "changeSearchLink",
event: "onclick",
popup: true,
params: {fragments: "searchForm"}
}));
</script>
This shows how a link is decorated with an Ajax Event to launch searchForm.jsp when the link is clicked.

Resources