Solved

Change text into Bold

Posted on 2001-06-08
14
225 Views
Last Modified: 2012-05-04
Hello all,

I am using the following HTML code to create a link in my page..

<DIV ID="LinkA"><A HREF=myURL" onClick= "MakeBold('LinkB')>LinkA</A></DIV>
<DIV ID="LinkB"><A HREF=myURL">Link B</A></DIV>

I want to make the link B bold when the link A is clicked? I tried to create a Java Script function, and pass the Id of the link B to it as a parameter, but what is the java script statment that change a text into bold?

Any idea?!!
Areej
0
Comment
Question by:Areej
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6168308
There is none.

You can change a STRING to bold by using
document.all('LinkB').innerHTML = document.all('LinkB').innerHTML.bold()
in IE

Alternatively use a stylesheet and change the class of the link

Michel
0
 

Author Comment

by:Areej
ID: 6168430
Thanx a lot..
It is working fine from Explorer, but what about Netscape?!

Many thanx,
Areej
0
 

Expert Comment

by:rogpereira
ID: 6168755
function MakeBold(l_obj) {
  document.all(l_obj).style.fontWeight = "bold";
}
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:Areej
ID: 6168847
Thanx a lot rogpereira, but that statment works only with Explorer. It is not working with Netscape. I'm getting "document.all has no properties" when I try to run it from netscape.

Any idea?!

Areej
0
 

Expert Comment

by:rogpereira
ID: 6168882
I'm sorry, but I don't work with Netscape.
0
 
LVL 9

Expert Comment

by:nimaig
ID: 6170429
You need to put your HTMLLink code in a
<DIV> or <LAYER> object and rewrite the content of the Layer everytime the Link A is clicked. That is the only possibility I know to make the thing work in Netscape.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6171209
Yep it is IE only.

So

<script>
boldText = '<A HREF="myURL"><B>Link B</B></A>'


function makeBold(divId) {
   if (document.all) {
      document.all(divId).innerHTML = boldText;
   }
   else if (document.layers) {
      with(document.layers[divId].document) {
        write(boldText);
        close()
      }
   }
   else if (document.getElementById) {
      document.getElementById(divId).innerHTML = boldText;
   }

   return false
}

<DIV ID="LinkA"><A HREF="myURL"
onClick= "return MakeBold('LinkB')>LinkA</A></DIV>
<DIV ID="LinkB" STYLE="position:absolute"><A HREF="myURL">Link B</A></DIV>

Another alternative is to have the two kinds of links in two layers and show one and hide the other

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6171210
Sorry missed a </script>
0
 
LVL 9

Expert Comment

by:nimaig
ID: 6171259
Michel -:
You missed the double quotes :
  i.e. it should be onClick= "return MakeBold('LinkB')"
and the method name must me makeBold('LinkB') not MakeBold('LinkB')

cheers :)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6171268
yeah - thanks

Michel
0
 

Accepted Solution

by:
hjainu earned 40 total points
ID: 6175748
<html>
<head>
<style>
.c1{
font-weight:"bold"
}
</style>
<script language="javascript">

function abc()
{
i1.className="c1"
}

</script>
</head>

<body>
<a href="url"><span  onClick=abc()>A Link</span></a>
<a href="url"><span id="i1">B Link</span></a>
</body>
</html>
0
 

Author Comment

by:Areej
ID: 6178470
Thanx a lot 4 all of u.. :-)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6178936
??????????

Michel
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6199003
mplungjan...

check the other q he answered!!
???
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question