Hi all,

its me again..I'm a newbie in javascript. I'm having trouble with the bold style in my javascript. It works fine in IE but not in firefox. Here's a code snippet of what I did.

var anchoryou = new Array(3);
anchoryou[0] = document.getElementById('First');
anchoryou[1] = document.getElementById('Second');
anchoryou[2] = document.getElementById('Third');

var sortvalue = GetUrlParameter('s');
var scope = sortvalue.substring(0,6);
var detector;

if (scope=="")
{

    detector=sortvalue.search("Thomas");
    if (detector != -1)
    {
        anchoryou[0].style.font="bold"; 
    }
    detector=sortvalue.search("Rowan"); 
    if (detector == "Second")
    {
        anchoryou[1].style.font="bold"; 
    }
    detector=sortvalue.search("Hartley");       
    if (detector == "First")
    {
        anchoryou[2].style.font="bold"; 
    }
    else
    {
    }

}

What will I do to make it work both on IE and Firefox???
Appreciate you response.

You are using a nonstandard IE extension to JavaScript.

The correct name for the style is "fontWeight", not "font".

Thanks..It worked on some of my pages...

However there's this one page that I changed with fontWeight that doesn't work.
Here's the code snippet.

var anchor = new Array(3);
anchor[0] = document.getElementById('Management');
anchor[1] = document.getElementById('Development');
anchor[2] = document.getElementById('Application');

var scope = GetUrlParameter('s');
var detector=document.getElementById("ctl00_ContentPlaceHolderMain_tellbox").value;
if (scope == "")
{
for(var i = 0; i < 3; i++)
    {
      if (anchor[i].getAttribute('name') == detector)
      {               
       anchor[i].style.fontWeight="bold";

      }

    }
}
else
{
for(var i = 0; i < 3; i++)
    {
      if (anchor[i].getAttribute('name')==scope)
      {       
       anchor[i].style.fontWeight="bold";

      }

    }
}

Can anyone help me on this...???
Would really appreciate it... :)

> However there's this one page that I changed with fontWeight that doesn't work.
Doesn't work is not a nice way to describe your problem. What exactly happens? Are there any javascript errors? Try opening the same page in Firefox and see if there is anything informative in the error console.

> anchor[i].getAttribute('name') IE doesn't like getAttribute() . Directly access the properties instead like anchor[i].name

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.