CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2001
    Location
    UK
    Posts
    308

    Difference in Script for NS and IE

    hi,
    1. i have a script for diplay drop down menus..using <div> method for IE 5.0.. can the same this be used for Netscape also.

    or where all we need to ensure that chnage in code for IE and NS.


    2. How to detmine the from which browser the page is being view..either from IE or NS..

    any idea..
    thanks in adv.

    Venu
    Venu Bharadwaj
    "Dream it. U can do it!"

  2. #2
    Join Date
    Jul 2002
    Location
    Don't Know, Don't Care
    Posts
    346
    first of all, ie and ns are html 4 compliant, divs are part of html 4 (i think they go back farther than that though).
    Second, post your code so we can show you how to cross-browser script.
    Third,
    Code:
    var browserName=navigator.userAgent;
    var browserVersion=parseInt(navigator.appVersion);
    function whatBrowser()
    {
    if (browserName=="Internet Explorer") //it may be MSIE, can't remember
    {
         window.location.url="iepage.htm";
    }
    else
    {
        window.location.url="nspage.htm";
    }
    }
    
    <body onload="whatBrowser()">

    C G C F A D--Feel the Noise

    "When your life goes nowhere and leads back to me, doesn't that tell you something?"
    ~Gray Area Fury

  3. #3
    Join Date
    Aug 2002
    Location
    Reykjavik, Iceland
    Posts
    201
    Here's a good way to do browser detection:

    if (document.all) {
    // IE4, IE5, IE6 specific code
    } else if (document.layers) {
    // NN4 specific code
    } else if (document.getElementById) {
    // NN6 specific code
    }


    Because both IE6 & NN6 support document.getElementById, you have to be sure to first check for document.all. Otherwise if you check for document.getElementById first, then IE6 will try to do your NN6 specific code.

    I haven't experimented much yet with NN7, but I assume the DOM is compatible with NN6.

  4. #4
    Join Date
    Dec 2001
    Location
    UK
    Posts
    308

    Menu in Java Script

    Hi,
    here is my code to show the drop down menu.. it is working fine in IE 5.0.... but it is not working in Opera.. i have not checked in Netscape..

    pl. find the my code in the attachmnet...

    pl. can u give input regrading this...

    thanks in adv..

    Venu
    Attached Files Attached Files
    Venu Bharadwaj
    "Dream it. U can do it!"

  5. #5
    Join Date
    Jul 2002
    Location
    Don't Know, Don't Care
    Posts
    346
    first of all, in your onmouse whatever statements where you change background colors, the netscape extension to css uses the background-color as opposed to backgroundColor, so, include the change for background-color as well in that event.
    Second, use if statements in the .js file
    Code:
    if (document.all)
    {
    ...
    }
    else
    if (document.layers)
    {
    mnuObj = document.layers[popmenu];
    ...
    }
    else
    if (document.GetElementById)
    {
    mnuObj=document.GetElementById(popmenu);
    ...
    }
    i think that about covers it

    C G C F A D--Feel the Noise

    "When your life goes nowhere and leads back to me, doesn't that tell you something?"
    ~Gray Area Fury

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

Featured