473,799 Members | 3,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript working in firefox but not IE

1 New Member
This script seems to work fine with firefox but not with IE. It just sets style="display: none" or style="display: " to show / hide submenu items on my menu. I've just tried making it save to a cookie which submenu is currently displayed and reopen that menu on a new page load.

checkCookie() is called onload and switchMenu(menu idhere) when the main menu item is clicked to make the submenu appear. Firefox doesn't display any js errors and reopens the correct menu on a page load whereas IE throws an "object required" error.


Expand|Select|Wrap|Line Numbers
  1. function switchMenu(obj) {
  2. var hid = "hide";
  3.     var el = document.getElementById(obj);
  4.     if ( el.style.display != "none" ) {
  5.         el.style.display = 'none';    
  6.         setCookie(hid,1);                
  7.     }
  8.     else {
  9.         el.style.display = '';    
  10.         setCookie(obj,1);    
  11.     }
  12. }
  13.  
  14.  
  15. function setCookie(menuid,expire)
  16. {
  17. var c = "menuid=" + escape(menuid) + ";expires=" + escape(expire);
  18.  //write cookie
  19. document.cookie = c;
  20. }
  21.  
  22. function checkCookie()
  23. {      
  24.  openmenu = getCookie('menuid'); 
  25. if (openmenu != 'hide') {  
  26.    switchMenu(openmenu);   //problem appears to be this line
  27.    }    
  28.    else { switchMenu("hide"); }
  29. }
  30.  
  31.  
  32.  
  33. function getCookie(cookieName) {
  34.  var theCookie=""+document.cookie;
  35.  var ind=theCookie.indexOf(cookieName);
  36.  if (ind==-1 || cookieName=="") return ""; 
  37.  var ind1=theCookie.indexOf(';',ind);
  38.  if (ind1==-1) ind1=theCookie.length; 
  39.  return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
  40. }
Nov 9 '07 #1
1 1682
acoder
16,027 Recognized Expert Moderator MVP
Can you also show the menu code.

Is the ID "hide"?
Nov 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
3678
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
7
9621
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script language="JavaScript"> var cntlName; var eleTarget = document.getElementById('hiding'); function showOrHide(){
13
1963
by: David Golightly | last post by:
I'm getting my feet wet with JavaScript 1.7 (Firefox 2.0 only) and messing around with it in the console, working through some of the exercises given at http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7 Looks like the "version" function isn't supported, at least not in the Firefox console. So many of the new features - especially using the "let" and "yield" keywords, as well as practical Array comprehensions which depend on...
16
2337
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript on the same page work correctly. It appears to be isolated to 1-2 machines in a particular network. I cannot verify whether these machines have had virus/spyware scans, but I do know the user is running Firefox 2.1 and IE 7 with the same...
1
1497
by: nitinp | last post by:
hello, I am trying to validate empty textbox value by javascript in Firefox. It is working fine in IE but not in Firefox. Note - code is for ASP.NET <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) Button1.Attributes.Add("onclick", "javascript:checkForm();");
12
2618
by: tim | last post by:
I am using foldoutmenu 3 and am having problems with viewing my menus in firefox. On my sub3 menus i have more than one line of text in some places. firefox does not recognise that there is more than one line and the text simply overlaps the sub-menus below it. I thought i had got around this by placing empty 'spacers' like so; oFoldMenu.make('sub3','')//spacer unfortunately, i have just viewed the site in IExplorer and it has added...
16
3540
by: eben | last post by:
I've been playing with the canvas primitive available in some of the modern browsers, and have put together a little 3d engine that I thought other people might find useful. See http://ajax3d.sourceforge.net/ I'd appreciate any feedback (and an explanation of why it doesn't seem to like Safari). Eben
2
1762
by: barrymars | last post by:
First posting here so bear with me. i'm working on a double tabbed menu system for a web aplpication, where the first row of 'divs' control visibility of the second row of 'divs'. It all works fine in IE7 but when i open it in firefox i only get the top row with nothing being rendered for the bottom row. some of the javascript is working because the top row changes colour when you roll the mouse over each tag. Thanks in advance for any...
5
19079
by: cbs7 | last post by:
Hi all I'm a complete newbie to web development and Javascript especially. I've been creating a form for a webpage and have used a validation script gen_validatorv2.js which I downloaded from the zip file referenced on http://www.javascript-coder.com/html-form/javascript-form-validation.phtml I managed to get everything working and was testing through Firefox that alerts were generated. However at the very end I thought I'd better check...
4
6048
by: iamaporkaholic | last post by:
The main page of the site has this script which determines the language settings of the OS. This works fine for IE but not for firefox. Is there any other codes which i have to insert to make sure Firefox would be able to load it? <script type="text/javascript"> function detectlang() { var lang=navigator.userLanguage var langs=navigator.systemLanguage
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10484
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.