Results 1 to 4 of 4

Thread: Javascript works in Firefox & not in IE???

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Location
    Ireland
    Posts
    23

    Javascript works in Firefox & not in IE???

    Hi all,

    Im have a problem getting this code to work in IE, it works perfectly in Firefox. Any help much appricated.

    Thanks JoePC

    Code:
    <html>
    
    <head>
    <title>DHTML & CSS for the WWW | Creating a Sliding Menu</title>
    <script language="JavaScript"><!--
    
    var open = 0;
    var slideSpeed = 10;
    var object = null;
    
    
    function setMenu (objectID) {
    object = document.getElementById(objectID);
    if (open) { fX = -80; cX = 0; open = 0; }
    else { fX = 0; cX = -80; open = 1; }
    slideMenu(cX,fX);
    }
    
    function slideMenu (cX,fX) {
    if (cX != fX) {
    if (cX > fX) { cX -= slideSpeed; }
    else { cX += slideSpeed; }
    object.style.left = cX + 'px';
    setTimeout('slideMenu(' + cX + ',' + fX + ')', 0);
    }
    return;
    }
    // -->
    </script>
    <style type="text/css"><!--
    body {
    margin-left: 30px
    }
    
    #mainMenu {
    top: 0;
    left: -80px
    }
    
    .menu {
    position: fixed;
    }
    
    a:link {
    color: red;
    font: bold 12px "Trebuchet MS", Arial, Helvetica, Geneva, sans-serif
    }
    
    --></style>
    
    </head>
    
    <body>
    <span id="mainMenu" class="menu">
    <table width="100" border="0" frame="frame" cellspacing="0" cellpadding="5" bgcolor="#999999">
    <tr>
    <td align="right" bgcolor="#cccccc" width="80"><a href="#">Option 1</a></td>
    <td rowspan="6" width="10">
    <div align="left">
    
    <a href="javascript:setMenu('mainMenu')" onFocus="if(this.blur)this.blur();"><img src="menuTab.gif" height="100" width="15" border="0" /></a></div>
    </td>
    </tr>
    <tr>
    <td align="right" width="80"><a href="#">Option 2</a></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#cccccc" width="80"><a href="#">Option 3</a></td>
    
    </tr>
    <tr>
    <td align="right" width="80"><a href="#">Option 4</a></td>
    </tr>
    <tr>
    <td align="right" bgcolor="#cccccc" width="80"><a href="#">Option 5</a></td>
    </tr>
    <tr>
    
    <td align="right" width="80"><a href="#">Option 6</a></td>
    </tr>
    </table>
    </span>
    </body>
    
    </html>

    Thanks again.....

  2. #2
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    If it works in gecko, why change it ?
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    I think it has to do with how getElementById is used....
    Try looking at http://www.dynamicdrive.com .... they've got tons of this stuff, and all marked as what it will and will not work on.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Code:
    href="java script:setMenu('mainMenu')"
    This is dodgy. Not only should it be an onclick, but if it is a href then javascript: should be together.

    Code:
    position: fixed;
    fixed is not supported in IE.

    Code:
    onFocus
    Since you're using XHTML (the img tag is XHTML style) this must be all lowercase.

    Code:
    <script language="JavaScript"><!--
    Along the same lines, you must use the type attribute (set it to "text/javascript") and must not use comments to hide the JS.


    That's what I see for now. The last two ought not to affect any browser.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width