I I have a Javascript code, that I want to initiate ONLY if a link is clicked.
I want to link to appear as a hyperlink, then when clicked, it will start the waiting code that will ask for the user's age, then it will cleanly redirect the parent page, without the need of popups or new windows.
If you can help, plz do so.
Thanks in advance.






mscreashuns posted this at 01:53—11th December 2007.
He has: 529 posts
Joined: Jul 2005
It could go something like this:
<html>...
<head>
<script language="javascript">
function makeUpACleverName() {
...code to ask for age...
window.location = "URL HERE";
}
</script>
</head>
...
<body>
<a href="#" onClick="makeUpACleverName()">Click here for the JavaScript thing</a>
</body>
</html>
'
You could also use CSS to disguise a regular tag as a link so you don't have to use a false target to have a link. Your CSS would look something like this:
.lookLikeALink {text-decoration: underline;
cursor: pointer;
...
}
'
Reece S posted this at 13:44—11th December 2007.
He has: 169 posts
Joined: Oct 2007
Ahh, this is similar to the script i made myself, i used this to verify mine, (which was wrong)
thanks for this, much appreciated.
webwiz posted this at 22:21—11th December 2007.
He has: 301 posts
Joined: May 2007
What's wrong with a regular link? (I see lots wrong with inline scripting, a link that goes nowhere, etc...)
I wonder what kind of answer you expect?
Cordially, David
--
"Old web developers don't die, they degrade gracefully..."
mscreashuns posted this at 00:06—12th December 2007.
He has: 529 posts
Joined: Jul 2005
I think using a regular link is just fine, but I don't see the need for one here, so that's why I offered a little styling help.
If it was redirecting to an actual new page, I would definitely suggest real links.