This demo tries to detect when the application is added to the homescreen by using a #hash token. You can also use a query string or a smart URL, but they are all guesstimate and there's a 20-30% chances of false positives. The good news is that false negative (ie: the call out being displayed when the app has been already added to the homescreen) should be very rare.
Remember that the only 100% safe way to use the add to homescreen feature is by using the apple-mobile-web-app-capable meta tag.