SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old March 3rd, 2005, 12:31 PM
pml pml is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 8 pml User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 17 sec
Reputation Power: 0
Question How can I make this tree menu work in Firefox and Netscape too?

I am experiencing some problems with my tree menu, because the plus
signs don't change to minus signs in Firefox and Netscape. The code
works just the way I want it to in IE. I guess that Firefox and Netscape
don't support the "innerText" but I just don't know how to make the
code cross browser compatible and make it look the same as here (one
main menu, 2 submenus, and some links contained in the submenus). I
have tried to change the "innerText" to "innerHTML" instead, but that
didn't make any difference.

I hope you have one or two ideas to make the code behave the way I want.


<html>
<head>
<title> My incompatible tree menu </title>

<style type="text/css">
a:link{text-decoration: none; color: 004884}
a:visited{text-decoration: none; color: 004884}
a:hover{text-decoration: underline; color: 004884}
font-family: verdana;}
</style>

<script language="javascript">

//Checks if menu is collapsed or expanded and then expands or collapses accordingly.

function Toggle(which, under) {
var visible = document.getElementById (which).style.display != "none"
//This is the div that should be expanded or collapsed.
var obj = document.getElementById (which)
//This is the div that is clicked to change the plus/minus sign.
var sub1 = document.getElementById (under)

if(obj.style.display = "none") {
obj.style.display = "block"
sub1.innerText = "–"
}

if(visible) {
obj.style.display ="none"
sub1.innerText = "+"
}
}

//Collapses the menu completely when called.
function close() {
divs = document.getElementsByTagName("div");
keys = document.getElementsByTagName("span");

for (i=0; i<divs.length; i++)
divs[i].style.display="none";

for (i=0; i<keys.length; i++)
keys[i].innerText ="+"
}

</script>
</head>

<body>

<table border="0" cellpadding="1" cellspacing="0">
<tr><td >
<a href="javascript:Toggle('menu1', 'sub1');">
<span id="sub1">+</span><b> &nbsp; Menu 1</b> </a>
</td></tr>
</table>

<div id="menu1" style="display: none; margin-left: 13px;">
<table border="0" cellpadding="1" cellspacing="1">
<tr><td>
<a href="javascript:Toggle('menu1.1', 'sub1_1');">
<span id="sub1_1">+</span> &nbsp; Submenu 1.1 </a>
</td></tr>
</table>

<div id="menu1.1" style="display: none; margin-left: 13px;">
<table border="0" cellpadding="1" cellspacing="1">
<tr><td>
<a href="menunumber.asp?submenu=1.1.1" target="main">
&nbsp; Go to URL 1.1.1 </a>
</td></tr>
<tr><td>
<a href="menunumber.asp?submenu=1.1.2" target="main">
&nbsp; Go to URL 1.1.2 </a>
</td></tr>
</table>
</div>

<table border="0" cellpadding="1" cellspacing="1">
<tr><td>
<a href="javascript:Toggle('menu1.2', 'sub1_2');">
<span id="sub1_2">+</span> &nbsp; Submenu 1.2 </a>
</td></tr>
</table>

<div id="menu1.2" style="display: none; margin-left: 13px;">
<table border="0" cellpadding="1" cellspacing="1">
<tr><td>
<a href="menunumber.asp?submenu=1.2.1" target="main">
&nbsp; Go to URL 1.2.1 </a>
</td></tr>
</table>
</div>
</div>

<table border="0" cellpadding="1" cellspacing="0">
<tr><td >
<a href="javascript:close();"><b>Collapse menu</b> </a>
</td></tr>
</table>

</body>
</html>

Reply With Quote
  #2  
Old March 3rd, 2005, 05:39 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Use "innerHTML" instead of innerText.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > How can I make this tree menu work in Firefox and Netscape too?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway