Layers issue in Netscape 4.x - tabs question

Discussion in 'Javascript' started by Jeannie, Apr 12, 2004.

  1. Jeannie

    Jeannie Guest

    Can anyone help me adjust this code so that it works in Netscape 4.x?

    I have am developing a website for a restaurant and the menu page has
    menus for lunch and dinner. Two images work as tabs, so that when you
    click on the lunch menu, only that menu is visible, and likewise, when
    you click on the dinner tab, only the dinner menu is visible.

    This code works like a charm on IE 5.5, but I don't know how to get a
    workable solution on Netscape. I suspect it's not so hard, but I need
    a little help.

    Thanks!!

    ******************************************
    <script language="javascript" type="text/javascript">
    var tabVisible = "tab1"

    function showTab(newTab) {
    newButton="b"+newTab;
    oldButton="b"+tabVisible.substr(3);
    show(oldButton,oldButton+".gif");
    show(newButton,newButton+"_over.gif");
    newTab="tab"+newTab;
    document.getElementById(tabVisible).style.visibility = "hidden";
    document.getElementById(newTab).style.visibility = "visible";
    tabVisible = newTab;
    }

    function newImage(arg) {if (document.images) {rslt = new Image();
    rslt.src = arg; return rslt;}}

    var preloadFlag = false;

    function preloadImages() {if (document.images) {
    b1sel = newImage("images/bt_menu_din.gif");
    b2sel = newImage("images/bt_menu_lun.gif");

    b1off = newImage("images/b1.gif");
    preloadFlag = true;}}

    function show(name,src)
    {if (document.images && (preloadFlag == true))
    document.images[name].src = "images/" + src;}

    </script>
     
    Jeannie, Apr 12, 2004
    #1
    1. Advertisements

  2. Jeannie

    Lee Guest

    Jeannie said:

    The change to your Javascript code is to rewrite showTab()
    as below. However, it still may not work, depending on
    whether or not Netscape 4 sees not your page elements as
    Layers.


    function showTab(newTab) {
    newButton="b"+newTab;
    oldButton="b"+tabVisible.substr(3);
    show(oldButton,oldButton+".gif");
    show(newButton,newButton+"_over.gif");
    newTab="tab"+newTab;
    if(document.getElementById){
    document.getElementById(tabVisible).style.visibility = "hidden";
    document.getElementById(newTab).style.visibility = "visible";
    }else if(document.layers){
    document.layers[tabVisible].visibility = "hidden";
    document.layers[newTab].visibility = "visible";
    }
    tabVisible = newTab;
    }
     
    Lee, Apr 12, 2004
    #2
    1. Advertisements

  3. Jeannie

    Jeannie Guest

    Thanks - I gave it a shot, but the menu tabs end up on the top of the
    page, but the description of the menu items aren't visible. Not sure
    what the fix would be, but thanks for your input!

     
    Jeannie, Apr 13, 2004
    #3
  4. Jeannie

    Jeannie Guest

    I am still in need of a solution, so if anyone knows how to make this
    tabbed script work for IE4+, NS4+, NS6+, please drop me a line.
    Thanks!!

     
    Jeannie, Apr 15, 2004
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.