Question

I was looking at the source of www.imdb.com and I noticed that there is a onclick attributes in every link.

I'm not very familiar with javascript, so i was wandering what's the purpose of the below code and why it's use.

(new Image()).src='/rg/OTW_3/HPRHS/images/b.gif?link=%2Ftitle%2Ftt1535438%2F';

link

<a href="/title/tt1815708/" onclick="(new Image()).src='/rg/OTW_7/HPRHS/images/b.gif?link=%2Ftitle%2Ftt1815708%2F';">Freelancers</a>
Was it helpful?

Solution

If you take a look at the location of the image that gets loaded (a 1x1 white pixel image), you'll see that it contains a more specific link to where you are clicking.

This is a way to do tracking on what's clicked and where. Because sites like IMDB have probably dozens of ways to get to any individual page, just tracking which sites get visited isn't enough. they are constantly tracking which links get hit more than others so that their interface can be better viewed and navigated. This is usually done for the better placement of ads.

Check out this other SO question that might answer your question (though your question is more fundamental while the other one is more technical..)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top