Works in IE but not in Netscape Or Firefox

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
fatman
Forum Commoner
Posts: 47
Joined: Fri Jul 21, 2006 11:18 am
Location: Portugal

Works in IE but not in Netscape Or Firefox

Post by fatman »

Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I "borrowed" a little something a looong time ago and basterdised it a lot and it worked just fine in IE. But now in Netscape and Firefox it doesn't. I hate to ask anyone to re-write "my" code, but please?

In the head:

[syntax="javascript"]<SCRIPT type="text/javascript">
var strItemLastClicked;

function doOutlineN(vRenglon) {
  var targetId, srcElement, targetElement;
 
    targetId = "OUT"+vRenglon.toString()+ "s";
  
    srcElement = "OUT"+vRenglon.toString()+ "t";

    srcElement = document.all(srcElement);
    targetElement = document.all(targetId);
     
    if (targetElement) {
      if (targetElement.style.display == "none") {
        targetElement.style.display = "";
      } else {
        targetElement.style.display = "none";
      }
    }
  
if (srcElement.className == "menu") {
	srcElement = srcElement.id; targetElement = document.all(srcElement)
	fncSubMenuFlip(srcElement);
	fncImgSwitch(targetElement);
}
}

function doOutline() {
  var targetId, srcElement, targetElement;
  srcElement = window.event.srcElement;
  if (srcElement.className == "MenuNivel1") {
    srcElement = srcElement.id
    //alert(srcElement);
    srcElement = srcElement.substr(0, srcElement.length-1);
 
    targetId = srcElement + "s";
  
    srcElement = srcElement + "t";

    srcElement = document.all(srcElement);
    targetElement = document.all(targetId);
     
    if (targetElement) {
      if (targetElement.style.display == "none") {
        targetElement.style.display = "";
      } else {
        targetElement.style.display = "none";
      }
    }
  }
/* New checks added to the onClick event function to handle submenuing in the main page area. */
if (srcElement.className == "menu") {
	srcElement = srcElement.id; targetElement = document.all(srcElement)
	fncSubMenuFlip(srcElement);
	fncImgSwitch(targetElement);
}
}

/* This function expands or collapses all of a menu's or submenu's items. */
function fncSubMenuFlip(oSource) {
switch (document.all(oSource + "_sub").style.display) {
case "none" :
document.all(oSource + "_sub").style.display = "";
strItemLastClicked = oSource;
break;

default:
document.all(oSource + "_sub").style.display = "none";
if (strItemLastClicked == oSource) {
strItemLastClicked = "";
}
break;
}
}
document.onclick = doOutline;
//-->
</SCRIPT>
In the body:

Code: Select all

  <tr align=left valign=middle> 
    <td height=22>
	<a class=MenuNivel1 id=OUT1t>• Bookings</a></td>
  </tr>
  <tr align=left valign=top> 
    <td> 
      <div id=OUT1s style="DISPLAY: none"> 
        <table align=right bgcolor="#0033cc" border=0 cellpadding=0 
                  cellspacing=0 width="92%">
          <tr> 
            <td class=MenuNivel2 height=18 width="11%"> 
              <div align=center>•</div>
            </td>
            <td height=18 valign=middle width="89%">
			<a class=MenuNivel2 href="left2.php">Left Refresh</a></td>
          </tr>
Just a snippet of the body text....


If anyone could have a browse and give a scream please



Weirdan | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Is this a tree type pop-up menu per chance?
User avatar
kbrown3074
Forum Contributor
Posts: 119
Joined: Thu Jul 20, 2006 1:36 pm

Post by kbrown3074 »

stupid question...are pop-ups enabled in firefox? Could firefox just be suppressing the pop-up?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Just use CSS?

Lot's of stuff to be found on Google about CSS pop-up menus.

Make sure you get the csshover2.htc so :hover will work correctly in IE.
User avatar
phppage
Forum Contributor
Posts: 126
Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK

Post by phppage »

For the JS I know Gecko browsers like Firefox select style objects differently. Below is a script I use to hide divs.

Code: Select all

function hideit(whatId) {
    	if (document.getElementById)
{document.getElementById(whatId).style.display = "none";}

	else {document[whatId].display = "none";}

	}
The If statement is true if run in IE but false in Firefox. In your script there is only the one option and thats the IE way.
Saying all this though I think Daedalus is right you might be better off getting some new script altogether or trying to do it in CSS.

Heres a real simple tutorial, helped me. :D

http://www.dustindiaz.com/dhtml-expand- ... -div-menu/[/url]
Post Reply