Solved

Change text into Bold

Posted on 2001-06-08
14
224 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

912 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now