473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Browser specific JavaScript error

I'm having a problem with submenu list. In my website I have code which populate a list of submenus onmouseover it works fine for IE but doesn't work for Mozilla and Chrome. Below is the code that.

Expand|Select|Wrap|Line Numbers
  1. <style>
  2. .menu { 
  3. color: #000000; font-family: arial; font-size: 11px; line-height: 12px;
  4.  padding-top: 3px;
  5. position: absolute; visibility: hidden; width: 175px; zindex: 99; 
  6. }
  7. .unnamed1 {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
  8. .txtheader1 {
  9. font-family: Verdana; font-size: 11px}
  10. </style>
  11. <script language="Javascript" src="fnc_menu.js"></script>
  12. <script language=javascript>
  13. <!--
  14. version = '0';
  15. var isMacIE = ( (navigator.userAgent.indexOf("IE 4") > -1) && (navigator.userAgent.indexOf("Mac")  > -1) );
  16. browserName = navigator.appName;           
  17. browserVer = parseInt(navigator.appVersion); 
  18. if (browserName == "Netscape" && browserVer >= 4)version = "n4";
  19. else if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) version = "e4";
  20.  
  21.     if (version == "n4" || version == "e4" && !isMacIE)     
  22.     {         
  23.         document.write('' +
  24.         '<div id=menu1 class="menu"><table  border=0 cellspacing=0 cellpadding=0>'+
  25.         '<tr>'+
  26.         '<td ><a href="company.asp" onmouseover="timer(1);MM_swapImgRestore();MM_swapImage(&quot;mp&quot;,&quot;&quot;,&quot;http://bytes.com/images/over_btn_ov.jpg&quot;,1);" onmouseout="timer(0);MM_swapImgRestore();" class=sub><img src="http://bytes.com/images/over_btn.jpg" name="mp" border="0"></a></td>'+
  27.         '<tr>'+
  28.         '<td ><a href="location.asp" onmouseover="timer(1);MM_swapImgRestore();MM_swapImage(&quot;mpp&quot;,&quot;&quot;,&quot;http://bytes.com/images/loc_t_btn_ov.jpg&quot;,1);" onmouseout="timer(0);MM_swapImgRestore();" class=sub><img src="http://bytes.com/images/loc_t_btn.jpg" name="mpp" border="0"></a></td>'+
  29.         '<tr>'+
  30.         '<td ><a href="team.asp" onmouseover="timer(1);MM_swapImgRestore();MM_swapImage(&quot;mpl&quot;,&quot;&quot;,&quot;http://bytes.com/images/team_t_btn_ov.jpg&quot;,1);" onmouseout="timer(0);MM_swapImgRestore();" class=sub><img src="http://bytes.com/images/team_t_btn.jpg" name="mpl" border="0"></a></td>'+
  31.         '</tr>'+
  32.         '</table>'+
  33.         '</div>' +
  34.  
  35.         '<div id=menu2 class="menu"><table  border=0 cellspacing=0 cellpadding=0>'+
  36.         '<tr>'+
  37.         '<td><a href="software.asp" onmouseover="timer(1);MM_swapImgRestore();MM_swapImage(&quot;mpll&quot;,&quot;&quot;,&quot;http://bytes.com/images/soft_t_btn_ov.jpg&quot;,1);" onmouseout="timer(0);MM_swapImgRestore();" class=sub><img src="http://bytes.com/images/soft_t_btn.jpg" name="mpll" border="0"></a></td>'+
  38.         '<tr>'+
  39.         '<td ><a href="tech_consult.asp" onmouseover="timer(1);MM_swapImgRestore();MM_swapImage(&quot;mplll&quot;,&quot;&quot;,&quot;http://bytes.com/images/tech_t_btn_ov.jpg&quot;,1);" onmouseout="timer(0);MM_swapImgRestore();" class=sub><img src="http://bytes.com/images/tech_t_btn.jpg" name="mplll" border="0"></a></td>'+
  40.         '<tr>'+
  41.         '<td ><a href="design.asp" onmouseover="timer(1);MM_swapImgRestore();MM_swapImage(&quot;mpllll&quot;,&quot;&quot;,&quot;http://bytes.com/images/des_t_btn_ov.jpg&quot;,1);" onmouseout="timer(0);MM_swapImgRestore();" class=sub><img src="http://bytes.com/images/des_t_btn.jpg" name="mpllll" border="0"></a></td>'+                 
  42.         '</tr>'+
  43.         '<td ><a href="fractit.asp" onmouseover="timer(1);MM_swapImgRestore();MM_swapImage(&quot;mpllll2&quot;,&quot;&quot;,&quot;http://bytes.com/images/fractit_t_btn_ov.jpg&quot;,1);" onmouseout="timer(0);MM_swapImgRestore();" class=sub><img src="http://bytes.com/images/fractit_t_btn.jpg" name="mpllll2" border="0"></a></td>'+                 
  44.         '</tr>'+
  45.         '</table>'+
  46.         '</div>' +
  47.  
  48.         '<div id=menu3 class="menu"><table  border=0 cellspacing=0 cellpadding=0>'+
  49.         '<tr>'+
  50.         '<td  ></td>'+
  51.         '<td ></td>'+
  52.         ' </tr>'+
  53.         '</table>'+
  54.         '</div>' +
  55.         '<div id=menu4 class="menu"><table  border=0 cellspacing=0 cellpadding=0>'+
  56.         '<tr>'+
  57.         '<td><a href="information.asp" onmouseover="timer(1);MM_swapImgRestore();MM_swapImage(&quot;mplllll&quot;,&quot;&quot;,&quot;http://bytes.com/images/info_t_btn_ov.jpg&quot;,1);" onmouseout="timer(0);MM_swapImgRestore();" class=sub><img src="http://bytes.com/images/info_t_btn.jpg" name="mplllll" border="0"></a></td>'+
  58.         '<tr>'+
  59.         '<td><a href="quote.asp" onmouseover="timer(1);MM_swapImgRestore();MM_swapImage(&quot;mpllllll&quot;,&quot;&quot;,&quot;http://bytes.com/images/get_t_btn_ov.jpg&quot;,1);" onmouseout="timer(0);MM_swapImgRestore();" class=sub><img src="http://bytes.com/images/get_t_btn.jpg" name="mpllllll" border="0"></a></td>'+
  60.         '</tr>'+
  61.         '</table>'+
  62.         '</div>' +
  63.  
  64.         '<div id=menu5 class="menu"><table  border=0 cellspacing=0 cellpadding=0>'+
  65.         '<tr>'+
  66.         '<td  ><a href="job_oppur.htm" onmouseover=timer(1); onmouseout=timer(0); class=sub><img src="http://bytes.com/images/oppur.jpg"  border="0"></a></td>'+
  67.  
  68.  
  69.         ' </tr>'+
  70.         '</table>'+
  71.         '</div>')
  72.     }
  73.  
  74. function MM_swapImgRestore() { //v3.0
  75.   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  76. }
  77.  
  78. function MM_findObj(n, d) { //v3.0
  79.   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  80.     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  81.   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  82.   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 
  83.   return x;
  84. }
  85.  
  86. function MM_swapImage() { //v3.0
  87.   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  88.    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  89. }
  90.  
  91. function MM_preloadImages() { //v3.0
  92.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  93.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  94.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  95. }
Please Help
Mar 26 '10 #1
1 1466
acoder
16,027 Expert Mod 8TB
Look at your code:
Expand|Select|Wrap|Line Numbers
  1. var isMacIE = ( (navigator.userAgent.indexOf("IE 4") > -1) && (navigator.userAgent.indexOf("Mac")  > -1) );
  2. browserName = navigator.appName;           
  3. browserVer = parseInt(navigator.appVersion); 
  4. if (browserName == "Netscape" && browserVer >= 4)version = "n4";
  5. else if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) version = "e4";
  6.  
  7.     if (version == "n4" || version == "e4" && !isMacIE)     
  8.     {         
It's old and ancient. It's checking for IE4+ and Netscape 4+ and ignoring everyone else! Get rid of the browser sniffing and there's a chance it may work in other browsers.
Mar 27 '10 #2

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

Similar topics

6
by: Alex Rast | last post by:
First of all, this is not a programming question. I'm a user, not programming in JavaScript. I'm not, however, a novice user or even a power user - I certainly know programming intimately as well...
5
by: DU | last post by:
Hi! I really need to understand what is so-called browser error correction mechanisms. Can you explain this? I read somewhere (and I no longer can find where I read that) that browsers try to...
1
by: francisco lopez | last post by:
hallo, I Have the following problem: I want to shake (earthquake-effect) the browser when someone hits the button. So I used the following script: ...
4
by: Frank Way | last post by:
Hi all, I've googled this one to death, and still can't find an answer. Not sure I'm asking the right question, but here goes: Have a form with an onSubmit that has some javscript to disable...
4
by: Robert M | last post by:
Hello, How can block the back button on the browser Thank you
3
by: Guy Debord | last post by:
Hello all, I know that this is a long shot, but I have a problem which someone reading this group *may* just be able to shed some light on. We have a new internal personnel planner/attendance...
4
by: iamthebest | last post by:
Hello, I am trying to call a javscript function from c#. But it is not getting called. The error comes up saying funtionname is not defined even though it is defined and visible in page source. ...
2
by: saggydel | last post by:
I have 3 web application these all are independent to each other. 1 web application have .aspx, .aspx.cs, web.config, .dll and some other Supporting files. I want to make a common setup of all 3...
10
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations...
5
Frinavale
by: Frinavale | last post by:
I was just wondering where/how JavaScript is loaded? Is it loaded for the specific page or for the Browser? I would have thought it was just specific to the page that the JavaScript exists within...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.