Topic awaiting preservation: a href=javascript:........... (Page 1 of 1) |
|
---|---|
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
posted 01-20-2003 03:55
I may be going about this all wrong but I'm playing around with some Javascript and the effect I want to have is a hyperlink that when clicked changes the bgColor... |
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
posted 01-20-2003 04:23
I think I figured it out.... |
Maniac (V) Mad Scientist From: New California |
posted 01-20-2003 04:26
That works just fine. You can also call a function. code: <html> |
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
posted 01-20-2003 05:09
ooooh I like that.... |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 01-20-2003 05:28
This: |
Maniac (V) Mad Scientist From: New California |
posted 01-20-2003 05:30
Cool, Slime, I didn't know you could use the void function like that. |
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
posted 01-20-2003 06:36
Tell me....is this incorrect too? If so what is wrong with it? code: <html>
|
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 01-20-2003 06:55
Boudga: the onmouseover and onclick events should *not* begin with "javascript:"; they should be pure javascript code (no prefix), and return false ("return false;") in order to keep the hyperlink from taking the user anywhere. The "javascript:" and the "void(stuff)" trick are only for the href="" attribute. |
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
posted 01-20-2003 07:03
Like this? code: onMouseout="document.bgColor='#000000';" "return false;"
|
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 01-20-2003 16:31
Not quite; remember, there's never more than one set of quotes for a single HTML attribute. Put it all inside the same set of quotes like this: |
Maniac (V) Inmate From: Brisbane, Australia |
posted 01-20-2003 17:02
Why would a mouseout need a false return? |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 01-20-2003 18:41
Oh, good point. The return false should only be necessary for onclick or maybe for onmouseup. |
Maniac (V) Mad Scientist From: New California |
posted 01-20-2003 19:33
I tried adding "return false;" to Boudga's original code and got errors. That is why I went to calling the function and was so pleased when I saw the void method. Did you guys get the "return false;" to work? |
Obsessive-Compulsive (I) Inmate From: Connecticut |
posted 01-21-2003 21:02
wow, never saw void used like that. Awesome, that clears things up in my head |
Maniac (V) Inmate From: Brisbane, Australia |
posted 01-22-2003 03:24
Umm.. Actualy, the javascript:viod(code...) example is in Netscape's Javascript 1.3 Reference. I thought everyone had that, it's a free PDF download. |