Php: Detect if user included the javascript-snippet or not, on their website
I got a simple javascript-file, wich my users need to include on their website for example. I want to detech if the snippet is include or not. The way I'm going to detect it, is by using a unique key in th开发者_运维百科e js-file, for anyone who needs to know.
Been searching a lot for this, but haven't come up with any results yet.
If you don't care about the response from the server but only want to detect the script loading on the server side, sending a small amount of data to the server, you can load a URL using the browser's image preloading feature:
new Image().src = "http://your.server.name/track.php?time=" +
new Date().getTime() + "&uniqueKey=" + uniquekey;
new Date().getTime()
ensures that the requested URL is unique, bypassing the web browser's cache.
You could have the JavaScript file make an Ajax call to announce its presence.
精彩评论