javascript not working in IE

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

javascript not working in IE

Post by Maz »

This causes the menu not to show in IE only.
What can I do?

Code: Select all

aI("text=Rate;showmenu=rate;status=rate;");
if( userIsMember){
aI("text=Member Area;showmenu=memberarea;status=member area;");
}
else{
aI("text=Members;showmenu=memberlogin;status=members login;");
}
}
Header background color no longer covers background image.

Thanks
maz
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

I didn't get the menu in NN 6 either, both ie and nn say 'userIsMember" is undefined. Whatever that means
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Maz,

How and where are you setting the userIsMember javascript variable? Is this on your www link, or do you have a test page we could see?

Kevin
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Hi Kevin,

Its on the template, and I removed the tools menu, now I only have a top menu. I removed the js so we could both work. But UK's asleep now so I'll put it back up with the js on the www link.

Is there another way to do the if else, I think IE is fussy.

Thanks,
maz
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Maz,

Right now at least, the main problem is that the userIsMember variable is undefined (doesn't exist) when the if/else in xtopmenu.js is processed. This isn't peculiar to IE; it'll fail in any browser. userIsMember is undefined when the if/else is processed in xtopmenu.js because of the following in the generated html:

Code: Select all

<script language="javascript" src="/template/main/xtopmenu.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
//<![CDATA[
var userIsMember;
//]]>
</script>
...the script that declares userIsMember is below where you load xtopmenu.js. Scripts are processed top-down, so userIsMember isn't declared until after it is needed in the xtopmenu.js code. Try this instead:

Code: Select all

<script language="javascript" type="text/javascript">
//<![CDATA[
var userIsMember;
//]]>
</script>
<script language="javascript" src="/template/main/xtopmenu.js" type="text/javascript"></script>
Another potential problem I'll mention is that userIsMember is declared, but isn't assigned a starting value. I assume that when a person first visits the sight, he or she is not logged in (and so, is treated as not a member by default). To be complete, you might want to assign a default value of 0 (or false) to userIsMember when you declare it, like so:

Code: Select all

var userIsMember = 0;
When a user selects the option to log in from the menu, I assume the login will regenerate the page (is it a php script?), setting userIsMember = 1. Again, userIsMember must be set before the menu script.

Hope that helps,

Kevin
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Thanks Kevin,

Its working again, it kept working in Safari but not other browsers. I messed up moving the menu in and out of tables.

Now even more so I need border-bottom on the main menu because I want the background to be transparent. I have no problem getting a border but I get 2 bottom borders due to submenu and subimage.

I've thought of using a bgimage but I can't position it bottom, an image wouldn't stretch with text.

Is there another way of putting style in the menu, like
offclass="bottom-border\"4px solid #ccc\";

Although if you try something like that you do get 2 borders on the main menu with a submenu subimage.

Thanks again,
maz
Post Reply