How do I capture the open-in-new-window/tab event?

L

laredotornado

Hi,

I have a link

<a href="download.pdf">Download</a>

and I'm interested in capturing the event when someone right-clicks on
the link and opens it in a new window/tab. Any advice you have is
greatly appreciated, - Dave
 
S

SAM

Le 23/08/10 20:47, laredotornado a écrit :
Hi,

I have a link

<a href="download.pdf">Download</a>

and I'm interested in capturing the event when someone right-clicks on
the link and opens it in a new window/tab. Any advice you have is
greatly appreciated, - Dave


and if I download the pdf instead of opening it somewhere ?

what is the interest knowing what made the visitor with documents you
serve ?


I'm not sure it can be possible to see what happens on a right-click
because the detecting function will be stopped as soon as the contextual
menu will display
 
E

Evertjan.

laredotornado wrote on 23 aug 2010 in comp.lang.javascript:
I have a link

<a href="download.pdf">Download</a>

and I'm interested in capturing the event when someone right-clicks on
the link and opens it in a new window/tab. Any advice you have is
greatly appreciated, - Dave

A new window/tab can also be forced in many browsers by a shift-click.
I do not see what right you have to know what way I look at the pdf.
So I am glad browser security does not allow you to see that in clientside
javascript.

However, perhaps if you had some "stay-alive" ajax connection to the
server, you could see serverside if the original page was or was not
overwritten by the pdf.

Forcing the page to be on a new window or tab can be done like this:

<a href='download.pdf' target='_blank'>Download</a>

Forcing the pdf to be downloaded and not shown in the browser,
can be done streaming the pdf with serverside javascript,
specifying "attachment":

<% // Javascript presumed
.....
var filePath = 'download.pdf';
var temp = 'attachment;filename=' + filePath;
Response.ContentType = 'application/pdf';
Response.Addheader('Content-Disposition', temp);
.....
%>
 
L

laredotornado

laredotornadowrote on 23 aug 2010 in comp.lang.javascript:




A new window/tab can also be forced in many browsers by a shift-click.
I do not see what right you have to know what way I look at the pdf.
So I am glad browser security does not allow you to see that in clientside
javascript.

However, perhaps if you had some "stay-alive" ajax connection to the
server, you could see serverside if the original page was or was not
overwritten by the pdf.

Forcing the page to be on a new window or tab can be done like this:

<a href='download.pdf' target='_blank'>Download</a>

Forcing the pdf to be downloaded and not shown in the browser,
can be done streaming the pdf with serverside javascript,
specifying "attachment":

<% // Javascript presumed
....
var filePath = 'download.pdf';
var temp = 'attachment;filename=' + filePath;
Response.ContentType = 'application/pdf';
Response.Addheader('Content-Disposition', temp);
....
%>

What I am taking from all this, is that it is not possible to capture
a right-click event. The reason I want to know is that we have
analytics software (Omniture) that counts clicks based on the
"onclick" event being fired. However, when people right-click, we are
noticing this event doesn't fire on Firefox or IE.

- Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top