Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getElementById help and formatting in Javascript

Status
Not open for further replies.

calypso13

Technical User
Nov 5, 2004
21
0
0
US
How do I make the script below work?. It makes the text bold but doesnt go to the default.html page link. The "return false" line stops it. I didnt want to create another stylesheet just to format this one tiny text. Is there a way to format this text in Javascript?

<A href="default.html" id="subject"> Subject</A>
onclick="document.getElementById('subject').style.fontWeight='bold';
return false;">
 
Code:
<A href="default.html" id="subject" [blue]onclick="document.getElementById('subject').style.fontWeight='bold';"[/blue] > Subject</A>

or this

Code:
<A href="default.html" id="subject" [blue]onclick="[red]this[/red].style.fontWeight='bold';"[/blue] > Subject</A>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook

 
Is there a way to make the text stay bold after the link has been visited? Without "return false;" the text doesnt stay bold, it just acts like a hover or active effect. And with the "return false;", href="default.html" is not processed.
 
why not just use CSS to do this?

Code:
<style>
  a:active, a:visited {font-weight: bold;}
</style>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook

 
Thanks for the help but I already tried that. It doesnt work. If I do this " a:active, a:visited {font-weight: bold;}" then the text will remain bold even when users click on a different link. I will figure out something else or way to do it. Thanks for all the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top