SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Oct 15, 2003, 13:51 #1
- Join Date
- Oct 2003
- Location
- los angeles
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How do I onUnload to get target url?
Say you have a script you are trying to direct through and some links are in flash and such and cant be tracked with the onClick method. I already set up a php script to track linkthroughs. I need to be able to track browser movement, because not all clickouts/change URLs are using href / html codes. I want to be able to track where users go when they leave my site. I want to use this with onUnload and not script every link and I need to find out where they are going and I'm trying to use the onUnload command. How do I do this or is there an alternative way?
-
Oct 16, 2003, 08:31 #2
- Join Date
- Dec 2002
- Location
- Alabama, USA
- Posts
- 2,560
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This little idea is the only thing I can think of right now. This example is IE-only. Let me know if you need help making it cross-browser.
Code:<html> <head> <script type='text/javascript'> window.onload = function() { document.onclick = docOnClick; } function docOnClick(e) { if (event.srcElement.tagName == 'A') { return confirm('Goodbye! Enjoy your trip to\n\n' + event.srcElement.href); } } </script> </head> <body> <p><a href='http://sitepointforums.com/'>SPF</a></p> <p><a href='http://sitepoint.com/'>SP</a></p> <p><a href='http://cross-browser.com/'>CB</a></p> </body> </html>
Cross-Browser.com, Home of the X Library
-
Oct 20, 2003, 18:27 #3
- Join Date
- Dec 2002
- Location
- Alabama, USA
- Posts
- 2,560
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Evidently this solved your problem.
You're welcome.Cross-Browser.com, Home of the X Library
Bookmarks