SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javasript and Netscape 6.2.3

    I use javascript to highlight the current page on the menu bar and also to drop down a submenu when the user clicks on a menu item. This works fine in Internet Explorer 6.0 but not in Netscape 6.2.3, and I do not understand why! The code can be viewed at www.candlewoodcc.com. For the rest of the site I use an include file with the menu, but the code is the same.

    Any suggestions?

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry - not really in the mood for prancing off round the internet. Can you post the code here please?

    I guess you're using window.focus() to highlight the page
    on the start bar - right?

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You appear to be using the proprietary Microsoft Document.all DOM to access the elements.

    This will only work in IE, and in any other browser that tries to play catch-up with microsoft by implementing it.

    Try replacing :
    sub_course.style.display="none";
    with
    document.getElementById("sub_course").style.display="none";

    That's the W3C DOM, which should work in IE, Mozilla (and its siblings, including N6), and maybe a few others I don't know about.

  4. #4
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for replying and here's more info. I don't use window.focus() to highlight the menu item, but rather javascript to load a different image that has the same text, but different color. To control both the highlight and the submenu opening I use <DIV> in the HTML code. I don't understand why it works in Internet Explorer 6.0 but not in Netscape 6.2.3. (Yes, I have checked the 'javascript enable' option in Netscape and when I go to other webpages, their javascript executes.)

    Here are the 2 javascript functions:
    <SCRIPT language="JavaScript">
    function highlight_menu_title(id) {
    if (id==0) {
    home_regular.style.display="none";
    home_highlight.style.display="block";
    }
    else if (id==1) {
    course_regular.style.display="none";
    course_highlight.style.display="block";
    }
    else if (id==2) {
    memberships_regular.style.display="none";
    memberships_highlight.style.display="block";
    }
    //etc...
    }

    function show_sub_menu(num) {
    if (num==0) { //Home
    sub_course.style.display="none";
    sub_membership.style.display="none";
    sub_tournaments.style.display="none";
    sub_social.style.display="none";
    sub_newsletter.style.display="none";
    sub_banquet.style.display="none";
    sub_dining.style.display="none";
    sub_profiles.style.display="none";
    sub_contactus.style.display="none";
    }
    if (num==1) { //The Course
    sub_course.style.display="block";
    sub_membership.style.display="none";
    sub_tournaments.style.display="none";
    sub_social.style.display="none";
    sub_newsletter.style.display="none";
    sub_banquet.style.display="none";
    sub_dining.style.display="none";
    sub_profiles.style.display="none";
    sub_contactus.style.display="none";
    }
    else if (num==2) { //Membership
    sub_course.style.display="none";
    sub_membership.style.display="block";
    sub_tournaments.style.display="none";
    sub_social.style.display="none";
    sub_newsletter.style.display="none";
    sub_banquet.style.display="none";
    sub_dining.style.display="none";
    sub_profiles.style.display="none";
    sub_contactus.style.display="none";
    }
    //etc...
    }
    </SCRIPT>
    Here is the HTML code:

    <!-- MENU BAR -->
    <TD width="175" valign="top" align="left">
    <TABLE width="175" valign="top" align="left"
    bgcolor="#D3DD8D" cellpadding="0" cellspacing="0">
    <!-- HOME -->
    <tr>
    <td align="left">
    <DIV id="home_regular" style="display:block;">
    <a href="index.html">
    <img src="images/home.gif" alt="Home page"
    border="0" width="150" height="22"></a>
    </DIV>
    <DIV id="home_highlight" style="display:none;">
    <img src="images/homehighlight.gif" alt="Home
    page" border="0" width="150" height="22">
    </DIV></td>
    </tr>

    <!-- THE COURSE -->
    <tr>
    <td align="left">
    <DIV id="course_regular" style="display:block">
    <a href="javascript:show_sub_menu('1');">
    <img src="images/thecourse.gif" alt="Open submenu
    for the course" border="0" width="150"
    height="22"></a>
    </DIV>
    <DIV id="course_highlight" style="display:none">
    <a href="javascript:show_sub_menu('1');">
    <img src="images/thecoursehighlight.gif"
    alt="The Course" border="0" width="150"
    height="22"></a>
    </DIV></td>
    </tr>
    <tr>
    <td align="left">
    <DIV id="sub_course" style="display:none">
    <a href="coursedescription.shtml">
    <img src="images/description.gif"
    alt="Course Description" border="0"
    width="150" height="15"></a>
    <a href="scorecard.shtml">
    <img src="images/scorecard.gif" alt="Scorecard"
    border="0" width="150" height="15"></a>
    </DIV>
    </td>
    </tr>
    <!-- ETC... -->
    </TABLE>

    <!-- HIGHLIGHT THE COURSE AND SHOW SUBMENU -->
    <SCRIPT language="Javascript">
    highlight_menu_title('1');
    show_sub_menu('1');
    </SCRIPT>
    </TD>

    I'll be happy to answer any other questions.

  5. #5
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a million, blufive, it works now!!!
    I am fairly new at this and didn't realize I was using a proprietary Document.all DOM from Microsoft. I need to learn more about this!

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    getElementById works in NS6 and ie 5+

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


Bookmarks

Posting Permissions

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