PDA

View Full Version : expanding menu not working in IE7 or Firefox



mwenn1
10-11-2006, 06:56 PM
I am working on code that someone else wrote and it is not working in IE7 or Firefox. It is for expanding menus, I hope some one can help me fix this.


here is the code from the index page:

<SCRIPT type="text/javascript">
<!--
var head="display:''"
var ie = document.all
var ns = document.layers

if (get_cookie(window.location.pathname) != ''){
var openresults=get_cookie(window.location.pathname).split(" ")
for (i=0 ; i < openresults.length ; i++){
expandmenu[openresults[i]].style.display=''
document.all[expandmenu[openresults[i]].sourceIndex -
1].style.listStyleImage="url(open.gif)"
}
}

if (document.all){
var nodelength=expandmenu.length-1
var nodes=new Array(nodelength)
var openones=''
}

if (document.all)
document.body.onunload=check

function inCell(cell, newcolor){
if (ie){
if (!cell.contains(event.fromElement)){
cell.bgColor = newcolor;
}
}
}

function outCell(cell, newcolor){
if (ie){
if (!cell.contains(event.toElement)){
cell.bgColor = newcolor;
}
}
}

function doit(header){
var head=header.style
if (head.display=="none")
head.display=""
else
head.display="none"
}

function check(){
for (i=0 ; i <= nodelength ; i++){
if (expandmenu[i].style.display=='')
openones=openones + " " + i
}
document.cookie=window.location.pathname+"="+openones
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
// if cookie exists
if (offset != -1) {
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
//-->
</SCRIPT>


this is a called include:

<script type="text/JavaScript1.2">
<!--

if (get_cookie(window.location.pathname) != ''){
var openresults=get_cookie(window.location.pathname).split(" ")
for (i=0 ; i < openresults.length ; i++){
expandmenu[openresults[i]].style.display=''
document.all[expandmenu[openresults[i]].sourceIndex -
1].style.listStyleImage="url(open.gif)"
}
}

if (document.all){
var nodelength=expandmenu.length-1
var nodes=new Array(nodelength)
var openones=''
}

function check(){
for (i=0 ; i <= nodelength ; i++){
if (expandmenu[i].style.display=='')
openones=openones + " " + i
}
document.cookie=window.location.pathname+"="+openones
}

if (document.all)
document.body.onunload=check

//-->
</script>


this is span that is to open/close which is also an include:

<% If Browser = "IE" Then %>
<script language="JavaScript1.2">
if (document.all)
document.write('<FONT SIZE=1 FACE="Verdana,Arial">Click the title to expand this section.</FONT>')
</script>
<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD BGCOLOR="#000080" VALIGN="top" ALIGN="left">
<IMG SRC="/includes/Main/graphics/leftend.gif" ALIGN="left" WIDTH=10 HEIGHT=20 HSPACE=0 BORDER=0>
<IMG SRC="/includes/Main/graphics/rightend.gif" ALIGN="right" WIDTH=10 HEIGHT=20 HSPACE=0 BORDER=0>
&nbsp;<B><FONT SIZE=3 COLOR=#FFFFFF FACE="Verdana,Arial" style="cursor:hand" onClick="doit(document.all[this.sourceIndex+1])">Related Links</FONT></B>
</TD>
</TR>
</TABLE>
<span id="expandmenu" style="display:none" style=&{head};>
<% Else %>
<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD BGCOLOR="#000080" VALIGN="top" ALIGN="left">
<IMG SRC="/includes/Main/graphics/leftend.gif" ALIGN="left" WIDTH=10 HEIGHT=20 HSPACE=0 BORDER=0>
<IMG SRC="/includes/Main/graphics/rightend.gif" ALIGN="right" WIDTH=10 HEIGHT=20 HSPACE=0 BORDER=0>
&nbsp;<B><FONT SIZE=3 COLOR=#FFFFFF FACE="Verdana,Arial">Related Links</FONT></B>
</TD>
</TR>
</TABLE>
<% End If %>
<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2 WIDTH=100%>
<TR>
<TD onmouseover="inCell(this, '#E3E4FF')" onmouseout="outCell(this, '#E1E1E1');" BGCOLOR=#E1E1E1><FONT COLOR="#000000" FACE="Verdana,Arial" SIZE=1><B><a href="http://www.test.com/" TARGET="_new">test.com</a></B></FONT></TD>
</TR>
</TABLE>
</span>

mwenn1
10-11-2006, 10:06 PM
nobody has any ideas here?