Solved

Change text into Bold

Posted on 2001-06-08
14
223 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now