Is it possible to use the onClick command to call up another file? or can it interface directly with a MySQL database?
I'm not sure what you are asking. JS runs client-side. All you can do is to send a request, which may do the DB work you need. For example: function onClick(event) { window.location = "domain/db-handler.ext?params"; } params will contain whatever you want to pass to MySQL. J.D.
Yes, looking at my request, it wasn't very clear. What it is, in my directory, there are coded and straight html links. The coded links, when clicked, as well as sending the user to the site, also run a cgi script (out.cgi?id=xxxx) that adds 'points' to the clicked sites' score for sorting the order of sites in the directory, by communicating with the MySQL database. I got the impression that it would be possible to use onClick to do the same function.
You can do this with JS - create a hidden frame and change its src on click (add link ID as a search argument). Another approach is to use redirect - hit the counting script first and pass the actual URL as a search argument. Use 302 redirect to point the browser to the actual page. J.D.
I don't want to use a redirect - I'm trying to remove the redirects and replace them with straight html links. Would the other method function like a straight html link for seo purposes?
JS will do what you need (when available, that is). You other and better option is to analyze your logs. I would rather do this. J.D.
I presume you mean manually check the outgoing clicks for each link. Unfortunately, that isn't really possible, with over 2000 links and climbing. The scoring is part of the link ordering of the directory, and really needs to be automated. Either I keep the current version, change to JavaScript, or abandon the scoring system completely.
Sorry, I shoul've been more specific. Here's some script to get you started: <script type="text/javascript"> function onClick(href) { document.getElementById("tracker").src = "tracker.app?url=" + encodeURI(href); return true; } </script> <img id="" src="some-image"> <a href="outgoing-link" onclick="return onClick(href)">click me</p> As a result of this, a request will be made to the tracker.app page with the URL passed as a search argument. All you will need to do is to analyze your logs for these search arguments. J.D.
When people click on the link, the function is called. This function changes image's src attribute so that it includes the actual link. At this point, the browser will make a request to your server for this image, including url= part. Then it will go to the actual link. As a result, your logs will contain the hits for this image and search arguments will contain url=outgoing-link, which is what you are looking for. Try this (it won't actually send the link, but will show you the image): <script type="text/javascript"> function onClick(href) { document.getElementById("tracker").src = "http://forums.digitalpoint.com/images/misc/dps_logo.gif?url=" + encodeURIComponent(href); return false; } </script> <img id="tracker" src="http://forums.digitalpoint.com/images/misc/dps_logo.gif"> <a href="http://forums.digitalpoint.com" onclick="return onClick(href)">click me</p> Before clicking on the link, check image's properties. The click on the link and check the properties again. This is what will end up in your log file. Once you change the return value to true, the browser actually will go to the href location. Also, there's a typo in the previous example - the id should say tracker (or whatever you choose instead). It is also better to use encodeURIComponent instead (see above). J.D.
JD ... This was helpful but I'm having trouble getting it to work using your exact code. Is it possible my hosting or server settings are not allowing the LOGGING. Basically, the original IMG is logged and the OnClick goes to the link... but the updated IMG with the URL is not getting LOGGED. Does this go to the ACCESS Log? Any help is appreciated! ... John M