Solved

Works in Mozilla - Not in IE6 - .className =

Posted on 2004-03-22
6
1,941 Views
Last Modified: 2008-03-17
Here's the URL:

http://www.t1shopper.com/dsl/index.shtml

The first navigation button, "DSL", should be yellow, not blue.  What am I missing?  The small scetion of the suspected area of the script is below.  The style sheet is below however, it validates so I don't think there's anything wrong there.

<head>
<script language="JavaScript1.2" type="text/JavaScript"><!--
document.getElementById('topmenu-dsl').className = "topmenuroll"
//--></script>
</head>

<body>
<a href="http://www.t1shopper.com/" id="topmenu-dsl"  class="topmenu">DSL</a>
</body>


.topmenuroll{
      background: #E5C350;
      color : #333333;
      display: block;
      font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
      font-weight : bold;
      font-size : 13px;
      line-height : 13px;
      text-decoration : none;
      width: 120px;
      border-top: 1px solid #FFFFFF;
      border-right: 1px solid #FFFFFF;
      border-left: 1px solid #FFFFFF;
      padding: 4px 4px 4px 6px
}
0
Comment
Question by:Geoff Millikan
  • 2
  • 2
  • 2
6 Comments
 
LVL 25

Expert Comment

by:devic
ID: 10654351
<script>
window.onload=function (){document.getElementById('topmenu-dsl').className = "topmenuroll"}
</script>
0
 

Author Comment

by:Geoff Millikan
ID: 10654451
I should have said I'm already calling the function like this: <body onLoad="navcolor();">  Sorry about that everyone.  So the script above should read: or check the URL at  http://www.t1shopper.com/dsl/index.shtml
------------------------------------------------------------
<head>
<script language="JavaScript1.2" type="text/JavaScript"><!--
function navcolor(){
document.getElementById('topmenu-dsl').className = "topmenuroll"
}
//--></script>
</head>

<body onLoad="navcolor();">
<a href="http://www.t1shopper.com/" id="topmenu-dsl"  class="topmenu">DSL</a>
</body>
--------------------------------------------------------------
0
 
LVL 25

Expert Comment

by:devic
ID: 10654492
add this :)

<table id=a><td> where is object with id=a???</td></table>
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 12

Accepted Solution

by:
lil_puffball earned 150 total points
ID: 10654563
Try changing this:

switch (arrURL[3]){
case 'dsl':
//Nested DSL Switch
switch (arrURL[4]){

to this:

switch (arrURL[arrURL.length-2]){
case 'dsl':
//Nested DSL Switch
switch (arrURL[arrURL.length-1]){
0
 

Author Comment

by:Geoff Millikan
ID: 10654943
devic - not sure where you were going with the id in the table tag?

lil_puffball -  Yes, that was it.  It's strage that Mozilla works just fine counting from string orgination (left to right) and IE6 requires counting from string termination to string origin (right to left).  These browser incompatibility issues never cease to amaze me.

Thank you all!  (And points go to lil_puffball because that solution worked and was easy to understand.)
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 10655072
Glad to help. Thanks for the points! :)

And just for further clarification:

In IE, the arrURL breaks up http://www.t1shopper.com/dsl/index.shtml into the following pieces:

http:
www.t1shopper.com
dsl
index.shtml

so arrURL[3] would be index.shtml, not dsl, and arrURL[4] would be undefined.
At first I was going to suggest using

switch (arrURL[2]){
case 'dsl':
//Nested DSL Switch
switch (arrURL[3]){

but later decided to start counting from the end because that would always work, no matter how many folders you have. :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…

809 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