ping Attribute
One of the attributes I somehow missed with the HTML5 revolution was the ping
attribute; Other attributes were more popular, download
being one of them. Hell, I just stumbled upon the ping
attribute while reading an old forum post. The ping
attribute of an a
element represents a list of URLs to POST to when the link is clicked.
A sample usage of the ping
attribute would look as follows:
<a href="/checkout" ping="/tracking/going-to-cart">Checkout</a>
I tried writing the POST data to file but the PHP $_POST
array was empty, so I can only assume no data is passed. As for why you'd use the attribute...I don't know. JavaScript tools provide tracking capabilities so I can only assume these POST pings can be coupled with session tracking to get more detailed information.
Have you used the ping
attribute before? If so please let me know what you used it for!
When you say or read "HTML5", you half expect exotic dancers and unicorns to walk into the room to the tune of "I'm Sexy and I Know It." Can you blame us though? We watched the fundamental APIs stagnate for so long that a basic feature...
If you follow me on Twitter, you know that I've been working on a super top secret mobile application using Appcelerator Titanium. The experience has been great: using JavaScript to create easy to write, easy to test, native mobile apps has been fun. My...
In my oh-so-humble opinion, Facebook's Modal box is the best modal box around. It's lightweight, subtle, and very stylish. I've taken Facebook's imagery and CSS and combined it with MooTools' awesome functionality to duplicate the effect.
The Imagery
Facebook uses a funky sprite for their modal...
I released a MooTools comment preview script yesterday and got numerous requests for a jQuery version. Ask and you shall receive! I'll use the exact same CSS and HTML as yesterday.
The XHTML
The CSS
The jQuery JavaScript
On the keypress and blur events, we validate and...
In a similar fashion to navigator.sendBeacon, the “ping” attribute fulfills the request in the background, thus it’s not suspcentible to common document unloading problems when sending requests..
Any sense of browser support?
I remember hearing about this many years ago (I think the last draft of specs to include it were in 2010, and it hasn’t been included since), but browser support was iffy. I think FF allows it only if the user modifies their about:config, there’s no real push for IE support, and Chrome/webkit supposedly support it but that’s not enough to recommend it’s use when it’s not on track to become a spec.
It was meant to be used primary for analytics and tracking, for the reasons Adam mentions (the request wouldn’t get canceled by the navigation itself).
It is designed for advertisers. The idea is to have a banner ad that links to the advertiser while having a click tracker go to the ad supply company without having to ad 3rd party JS that who knows what it does.
Since this is designed for advertisers, Google obviously has it working in Chrome, but Firefox doesn’t really care. Because of this, the ad industry just makes the click through url hit the ad supply site for tracking and then it redirects you to the actual ad url.
Just see that Google use it on results search links