Forum Moderators: open
For instance, given the following link:
<a href="link.html">click here</a>
how do i allow a click the first time, yet disable it for future clicks from the same user in the same browser window.
I've tried disabling the link using the onclick event, but it seems to only grey out the link yet still allow clicks.
can anyone help?
thanks!
jeff
No seriously, if I had to do this I would make the link disappear instead of disabling it (like in my previous post). Something that isn't there is less annoying than something that is there and doesn't work.
a.disappear:visited {
display:none;
}
<a href="" class="disappear">Click once</a>
<html>
<head>
<script type="text/javascript">
function disableLink(url) {
document.write("<style type='text/css'>.disLink {display:none;}</style>");
location.href = url;
}
</script>
</head>
<body>
<a href="javascript:disableLink('http://www.example.com');" class="disLink">test</a>
</body>
</html>
Try this. It's untested in any browsers other than IE.
as always, there's more to my story/problem...
the link i'm trying to keep from multiple clicks is being served in a banner on a banner ad. the banner ad is served on a PPC basis, hence the reason to only allow one click per time it's served.
unfortunately, i don't have control over the pages that the ad may be served on... so i don't think i can use an external style sheet (or could i?).
is there a way to increment a some sort of a counter to see if it's been clicked once already, and if so, hide the banner (or make it unclickable)?
any other suggestions?
thanks so much for all your help!
btw... the CSS solution only seems to work in IE for me...
Does the ad always appear in the same location?
If so, could you not just capture the mouse position when clicked and if it's in the banner area, make a layer appear covering the banner?
It could either be a transparent layer, or a layer saying thanks for the clicks... or you could even serve another banner.
This may or may not work, but as a brainstorm. How about having an invisible gif image cover the banner after the first click using js.
Notes:
-This might be against the TOS of the banner provider. I am sure it's against adsense's.
- Once clicked, I assume one has to click on the browsers back button, which usually serves the cached version and thus no distinction can be made with first or later clicks. The workaround might be to have the page refresh automatically and at a fast rate.