Javascript Initiate Sequence

DarkLight's picture

He has: 287 posts

Joined: Oct 2007

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.

All the best news here: https://newsbotnet.com

He has: 698 posts

Joined: Jul 2005

It could go something like this:

<html>
...
<head>
&lt;script language="javascript"&gt;
function makeUpACleverName() {
...code to ask for age...
window.location = "URL HERE";
}
&lt;/script&gt;
</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;
...
}
'

Kurtis

DarkLight's picture

He has: 287 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.

He has: 629 posts

Joined: May 2007

What's wrong with a regular link? (I see lots wrong with inline scripting, a link that goes nowhere, etc...)

Quote: it will start the waiting code that will ask for the user's age

I wonder what kind of answer you expect? Laughing out loud

Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;

He has: 698 posts

Joined: Jul 2005

webwiz;227220 wrote: What's wrong with a regular link?

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. Wink

If it was redirecting to an actual new page, I would definitely suggest real links.

Kurtis

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.