Sanding our assholes with 150 grit.

Javascript: How do I?

How do I attach a "listener" to a hyperlink such that clicking the hyperlink will fire off a function before the browser actually requests the document in the href?

If I put something in onClick, doesn't that override the click and prevent the browser from requesting the linked URL?  Or will it do both?
Permalink Send private email muppet 
September 9th, 2006 7:03pm
<script>
function myFunction(){
//do stuff

document.window.location = "www.blah.com";
}
</script>



<a href="javascript:myFunctions()">My Link</a>
Permalink Funny Bünny 
September 9th, 2006 7:09pm
Why not add document.location.href = "whereveryouwanttogo" to the end of the call to the listener?  Doesn't answer your question exactly, but it avoids the need to even ask it. :)
Permalink Send private email Mat Hall 
September 9th, 2006 7:10pm
Thanks.  I think I see how to modify that for my framed situation.

And I assume that if a user is blocking ALL javascript, the link will just work off the href attribute.
Permalink Send private email muppet 
September 9th, 2006 7:11pm
Alternatively, this would take you... like, five seconds to try.
Permalink Colm 
September 9th, 2006 7:11pm
if I do href="mylocation" onClick="myfunction" anyway.
Permalink Send private email muppet 
September 9th, 2006 7:11pm
Easier to ask since you're all so knowlegable.  I'm going for efficiency here, Colm.
Permalink Send private email muppet 
September 9th, 2006 7:12pm
That'll work.
Permalink Send private email Mat Hall 
September 9th, 2006 7:12pm
Right, why bother wasting 5 seconds of your own time when you can waste ours instead?
Permalink Colm 
September 9th, 2006 7:13pm
Yeah, like any of us was doing anything productive. :)
Permalink Send private email Mat Hall 
September 9th, 2006 7:13pm
Colm just likes so find fault with me because he's secretly so jealous of me that it makes him cry at night.
Permalink Send private email muppet 
September 9th, 2006 7:19pm
Uuuuh... jealous of what?
Permalink Funny Bünny 
September 9th, 2006 7:23pm
Dude, what's NOT to be jealous of when it comes to me?  I'm so fucking awesome it makes ME cry.
Permalink Send private email muppet 
September 9th, 2006 7:24pm
Right. Carry on muppy.
Permalink Funny Bünny 
September 9th, 2006 7:25pm
>Dude, what's NOT to be jealous of when it comes to me?

Every other post on here is a complaint about your life. Either your job sucks, you're ill because of your drugs or you're poor.
Permalink Colm 
September 9th, 2006 7:31pm
lol
Thats a pretty acurate list.
Permalink Funny Bünny 
September 9th, 2006 7:35pm
" Either your job sucks, you're ill because of your drugs or you're poor."

heh. and every second post you make is attacking muppet.

so...which of you has the sadder life?
Permalink worldsSmallestViolin 
September 9th, 2006 7:57pm
Yeah, and like muppet is any different.
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 8:01pm
true.  every second post muppet makes is _also_ about muppet.

<g> but I put it to you that muppet has rather more of an investment in muppets life than Colm has.

...at least, I would have thought so...
Permalink worldsSmallestViolin 
September 9th, 2006 8:03pm
Lets stop derailing the thread, muppet is boring
Permalink what are you snorting for? 
September 9th, 2006 8:06pm
His posts are boring.

Muppet himself is a fun subject :)

Just like a bot is a fun subject...
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 8:08pm
>but I put it to you that muppet has rather more of an
>investment in muppets life than Colm has.

Gee, I hate to agree with you here, but I really DON'T care about muppet's life. I care even less about how much you care about me not giving a shit about muppet, however, and I'm frankly baffled as to why you give a shit about me.

Put simply... why are you still talking?
Permalink Colm 
September 9th, 2006 8:08pm
He's probably still talking for the same reason you just made that post, Colm.
Permalink Send private email Aaron F Stanton 
September 9th, 2006 8:09pm
Because I can.
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 8:10pm
The proper way to do it would be (with prototype)

<a id="hi" href='http://crazyontap.com' > Link 1 </A>

<script >

Event.observe( $('hi'), "click", function1, true);


function1 = function(e){
  Event.stop(e); // Stops the click event
  //Do Stuff

  //If you want still to trigger the click funcion
  Event.element(e).click();

}

</script>

But yeah, the others also work :)
Permalink Send private email Masiosare 
September 9th, 2006 8:13pm
>He's probably still talking for the same reason you just
>made that post, Colm.

Which was?
Permalink Colm 
September 9th, 2006 8:13pm
"I really DON'T care about muppet's life."

interesting.  you claim that, but yet I still read a _lot_ of posts by you about muppet, his life and his posting techniques.

seems like a lot of work for someone who doesn't care about the topic.


"Put simply... why are you still talking?"

becaues I get a real kick out of baiting people less intelligent than myself.
Permalink worldsSmallestViolin 
September 9th, 2006 8:15pm
You can really tell who are young and who aren't.
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 8:16pm
>interesting.

Ah, see that's where you went wrong. You're actually being very, very dull.
Permalink Colm 
September 9th, 2006 8:18pm
Interesting enough to get Ms WsV
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 8:20pm
"who are young and who aren't"

You really aren't ever going to get the hang of this English language thing, are you Rick? :-)

You have been living in Canada for a good many years now, and you must therefore have to speak English every day. Why do you have so much trouble learning it?
Permalink Send private email bon vivant 
September 9th, 2006 8:30pm
Cause no one is correcting your mistakes.

And I don't really want to learn!
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 8:32pm
> And I don't really want to learn!

As the saying goes, once in Rome... If you don't want to learn it, why did you move there?
Permalink Funny Bünny 
September 9th, 2006 8:39pm
I mean I don't want to perfect it.

There are more important stuff to learn and do.
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 8:41pm
Such as what?
Permalink Colm 
September 9th, 2006 8:42pm
Oh, perhaps I am just lazy.

It's too hard to move back.
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 8:42pm
> It's too hard to move back.

How good is your cantonese, btw?
Permalink Funny Bunny 
September 9th, 2006 9:16pm
Very good.

On the other hand, writing proper Chinese is ever harder, and I have not do it for far too long to catch up.
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 9:28pm
Have not done...
Permalink Send private email Rick Zeng/Tseng 
September 9th, 2006 9:30pm
Basically, you're an international analphabet. If the canadian government wanted to deport you, they'd be fucked.
Permalink Funny Bünny 
September 10th, 2006 6:18am

This topic is archived. No further replies will be accepted.

Other topics: September, 2006 Other topics: September, 2006 Recent topics Recent topics