[whatwg] <a href="" ping="">

Ian Hickson ian at hixie.ch
Fri Oct 21 14:14:46 PDT 2005


On Fri, 21 Oct 2005, Charles Iliya Krempeaux wrote:
> 
> For #2, I can tell you that advertising software will NOT use this 
> unless they absolutely know it works.  There'd need to be some way of 
> detecting browsers that it works on.  Without having to resort to 
> browser detecting.  Need to do "feature detecting".  (I.e., don't want 
> to have to check for specific versions of specific browsers.  But want 
> to check to see what "features" whatever browser they are on has.)
>
> For alot in the advertising industry, clicks are their "bread and
> butter".  It's where the money comes from.  They MUST be able to
> "record" a click.

Oh, I know. My salary comes almost entirely from Web advertising. :-)


> Also, it is often necessay to "ping" more than one URI.  So you might 
> want to make a system where you can list more than one URI.  (Although I 
> guess you could just have one "ping" URI and do redirect tricks with 
> it.)

As currently defined the ping="" attribute takes a space-separated list of 
URIs, so this should be already taken care of.


> Back to "feature detecting" though.  Maybe if we had a kind of loopback 
> "ping" that would work.  (If that makes sense.)  That way a document 
> could initiate a "ping" to somewhere it would be able to detect.

You can detect whether the UA supports it or not by putting the attribute 
in uppercase:

   <a href="http://example.com" PING="redirect?uri=http%3A%2F%2Fexample.com">

...and then in the script checking to see if the ".ping" DOM attribute 
exists or not. If it doesn't, copy the value of PING into href:

   var links = document.getElementsByTagName('a');
   for (var i = 0; i < links.length; i += 1)
     if (!links[i].ping && links[i].getAttribute('ping'))
       links[i].href = links[i].getAttribute('ping');

Run this script once per page and it'll switch you back to using the old 
method of redirects, with the new user agents (that support ping) having a 
better UI. You could also do the same in reverse with slightly more 
complicated JS if you wanted to default to the href="" method for non-JS 
browsers (which would make sense until ping="" support is widespread).

Thanks for your input!
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list