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

  • Follow


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

0
Reply laredotornado 8/23/2010 6:47:43 PM

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

-- 
St�phane Moriaux avec/with iMac-intel
0
Reply SAM 8/24/2010 2:13:39 AM


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);
.....
%>


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
0
Reply Evertjan 8/24/2010 8:33:22 AM

On Aug 24, 3:33=A0am, "Evertjan." <exjxw.hannivo...@interxnl.net> wrote:
> laredotornadowrote on 23 aug 2010 in comp.lang.javascript:
>
> > I have a link
>
> > <a href=3D"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. =A0Any 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 clientsid=
e
> 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=3D'download.pdf' target=3D'_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 =3D 'download.pdf';
> var temp =3D 'attachment;filename=3D' + filePath;
> Response.ContentType =3D 'application/pdf';
> Response.Addheader('Content-Disposition', temp);
> ....
> %>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

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
0
Reply laredotornado 8/24/2010 1:13:58 PM

3 Replies
777 Views

(page loaded in 0.19 seconds)

Similiar Articles:













7/25/2012 6:46:42 AM


Reply: