From: Csaba Gabor on
On Jun 21, 12:51 pm, SAM <stephanemoriaux.NoAd...(a)wanadoo.fr.invalid>
wrote:
> Le 6/21/10 11:13 AM, Csaba Gabor a crit :
>
> > How can I most reliably detect when a link has been clicked to open in
> > a new tab or to open in a new window?  I have not found this question
> > well adressed in the pages returned up my searches.
>
> > I am doing some statistics gathering.  In particular, I have some
> > links that point to external websites (they are product links) and I
> > would like to know when they are clicked, to verify against what the
> > destination site reports.  If they are clicked "normally", to open in
> > the same window, it is no problem because one just adds an onclick
> > handler to the link.
>
> So, your counter works only if JS is enabled ? !

Correct. There is no pretense here that I am
collecting all possible link activations. In fact,
I have one snippet of code (for the main page) to
detect whether JS is enabled, and another that
checks for cookies (this is to try to gain an
understanding of how people are coming to the
site), and another to check whether the page is
a chached copy. None of these effects the
minimal functionality of the site.

Oh, and the site is pretty basic - it's just a
short list of (ballpark 60) items (books) with
reviews, separated onto 3 distinct pages.
Nonetheless, google indexes it highly so I do
get visitors, though it's a fairly fresh site.

> > All my onclick handler does is to send a request
> > out via an embedded Iframe (so it can be logged by the server), and
> > this request gets sent before the new page starts to load.
>
> If is only a question of clicks count,

I am specifically after all actual product link
'activations' that I can be certain of without
introducing any false positives. Therefore,
click counts are not sufficient.

> instead of onclick maybe onmousedown, onmouseup ?
> Or detect the no left-click on mouse down ?

Thanks for this sample code. I am doing on
onclick what you are doing in onmousedown.
That gives me actual link openings in the current
window. However, as I read this code, it doesn't
cover me for right clicks.

> <a href="http://google.com"
> onmousedown="var e = event.wich||event.button;
>   if(e>1) parent.myInvisibleIframe.location='myCountr.php?c='+this.href;"
> onclick="window.open('myCountr.php?c='+this.href,'view','width=300,height=3­00');
>           return false;">test with google</a>
>
> <iframe name="myInvisibleIframe"
> style="visibility:hidden;width:1px"></iframe>
>
> (not tested with IE)
> --
> sm
From: Gregor Kofler on
Am 2010-06-21 11:13, Csaba Gabor meinte:
> How can I most reliably detect when a link has been clicked to open in
> a new tab or to open in a new window? I have not found this question
> well adressed in the pages returned up my searches.

Because you can't.

Gregor


--
http://www.gregorkofler.com
From: Csaba Gabor on
On Jun 21, 12:53 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> Csaba Gabor wrote:
> > How can I most reliably detect when a link has been clicked to open in
> > a new tab or to open in a new window?  I have not found this question
> > well adressed in the pages returned up my searches.
>
> You have not found anything because you can't do this

Your argument, or lack thereof, is not convincing.
By saying that I can't do this, you are asserting
that there is no detectable change in/on the page
that has had such a link clicked. Is that really
true?

> nor should you try.

Your pronouncment on my value system does not
belong in this forum. "I would not try,"
would be much more believable, though perhaps
not very relevant.

> PointedEars
> --
> var bugRiddenCrashPronePieceOfJunk = (
>     navigator.userAgent.indexOf('MSIE 5') != -1
>     && navigator.userAgent.indexOf('Mac') != -1
> )  // Plone, register_function.js:16
From: Asen Bozhilov on
Csaba Gabor wrote:

> How can I most reliably detect when a link has been clicked to open in
> a new tab or to open in a new window?  I have not found this question
> well adressed in the pages returned up my searches.
>
> I am doing some statistics gathering.  In particular, I have some
> links that point to external websites (they are product links) and I
> would like to know when they are clicked, to verify against what the
> destination site reports.  If they are clicked "normally", to open in
> the same window, it is no problem because one just adds an onclick
> handler to the link.  All my onclick handler does is to send a request
> out via an embedded Iframe (so it can be logged by the server), and
> this request gets sent before the new page starts to load.

One possible approach is server side proxy. If you detect click on
link log statistic and request external page in iframe, otherwise
request your page on same server. There will be server side script
which log statistic and relocate to external page. In my opinion that
is simple solution for your problem.

From: Thomas 'PointedEars' Lahn on
Csaba Gabor wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Csaba Gabor wrote:
>> > How can I most reliably detect when a link has been clicked to open in
>> > a new tab or to open in a new window? I have not found this question
>> > well adressed in the pages returned up my searches.
>>
>> You have not found anything because you can't do this
>
> Your argument, or lack thereof, is not convincing.
> By saying that I can't do this, you are asserting
> that there is no detectable change in/on the page
> that has had such a link clicked.

No, I am asserting that there is no reliable way to detect this, since that
was your condition.

> Is that really true?

Your logic is flawed.

>> nor should you try.
>
> Your pronouncment on my value system does not belong in this forum.
> "I would not try," would be much more believable, though perhaps
> not very relevant.

Reading luser responses such as this makes me wonder why I still bother
investing my free time for an answer, offering my knowledge and experience
for free.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16