tree menu in dhtml

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andromeda

    tree menu in dhtml

    I've been trying to add a tree menu to my website with some luck (more
    or less). I came across a script on simplythebest.n et, but I seem to
    be having a problem with it... and since they have no help section,
    this has brought me here.

    The script can be found at

    (no login or anything required... I just thought the script might be
    too long to repost here)

    The problem:

    It says to change the number 22 in the line
    function makeDatabase() {
    outline = new makeArray(22)
    to the number of outlines plus one. Well, It turns out I'm going to
    need around 40 or so outlines, but when I change the number to 40 or
    41 (however many I added plus one) it only shows the first 20 or so
    outlines on my page and just cuts off the rest. I'm still learning
    dhtml and javascript, so I don't know what else I can change to have
    it show the other 20something links.

    Any thoughts would be most helpful.

    Thanks!
  • Mark Parnell

    #2
    Re: tree menu in dhtml

    On 15 Sep 2004 00:12:35 -0700, Andromeda <tuoni42@hotmai l.com> declared
    in comp.infosystem s.www.authoring.html:
    [color=blue]
    > http://simplythebest.net/scripts/DHT...cript_100.html[/color]
    [color=blue]
    > Any thoughts would be most helpful.[/color]

    Without Javascript, not only does the menu not work, it doesn't even
    exist.

    --
    Mark Parnell

    Comment

    • Andromeda

      #3
      Re: tree menu in dhtml

      Mark Parnell <webmaster@clar kecomputers.com .au> wrote in message news:<13cc3s0o1 fp83.1ntc511c5q spc$.dlg@40tude .net>...[color=blue]
      > On 15 Sep 2004 00:12:35 -0700, Andromeda <tuoni42@hotmai l.com> declared
      > in comp.infosystem s.www.authoring.html:
      >[color=green]
      > > http://simplythebest.net/scripts/DHT...cript_100.html[/color]
      >[color=green]
      > > Any thoughts would be most helpful.[/color]
      >
      > Without Javascript, not only does the menu not work, it doesn't even
      > exist.[/color]


      Should I assume this means you have scripts disabled on your machine?
      I'm not really sure what I need to do with this response since its
      worked fine on every browser/computer I've tried it on.

      Comment

      • Neal

        #4
        Re: tree menu in dhtml

        On 15 Sep 2004 08:52:05 -0700, Andromeda <tuoni42@hotmai l.com> wrote:
        [color=blue]
        > Mark Parnell <webmaster@clar kecomputers.com .au> wrote in message
        > news:<13cc3s0o1 fp83.1ntc511c5q spc$.dlg@40tude .net>...[color=green]
        >> On 15 Sep 2004 00:12:35 -0700, Andromeda <tuoni42@hotmai l.com> declared
        >> in comp.infosystem s.www.authoring.html:
        >>[color=darkred]
        >> > http://simplythebest.net/scripts/DHT...cript_100.html[/color]
        >>[color=darkred]
        >> > Any thoughts would be most helpful.[/color]
        >>
        >> Without Javascript, not only does the menu not work, it doesn't even
        >> exist.[/color]
        >
        >
        > Should I assume this means you have scripts disabled on your machine?
        > I'm not really sure what I need to do with this response since its
        > worked fine on every browser/computer I've tried it on.[/color]

        Client side scripting must be assumed off in design. Test with it off.

        Whether or not the browsers you've used show the site to function, the
        recommendations allow UAs to ignore scripts. So your design must account
        for that reality.

        If you MUST use client-side scripting to make links, provide a real link
        alternative so content can be accessed.

        Comment

        • Alan J. Flavell

          #5
          Re: tree menu in dhtml

          On Wed, 15 Sep 2004, Andromeda wrote:
          [color=blue]
          > Should I assume this means you have scripts disabled on your machine?[/color]

          Doesn't everyone, when visiting untrusted web pages? :-}
          [color=blue]
          > I'm not really sure what I need to do with this response since its
          > worked fine on every browser/computer I've tried it on.[/color]

          You're new around here, evidently.

          Comment

          • Stephen Poley

            #6
            Re: tree menu in dhtml

            On 15 Sep 2004 08:52:05 -0700, tuoni42@hotmail .com (Andromeda) wrote:
            [color=blue]
            >Mark Parnell <webmaster@clar kecomputers.com .au> wrote in message news:<13cc3s0o1 fp83.1ntc511c5q spc$.dlg@40tude .net>...[color=green]
            >> On 15 Sep 2004 00:12:35 -0700, Andromeda <tuoni42@hotmai l.com> declared
            >> in comp.infosystem s.www.authoring.html:
            >>[color=darkred]
            >> > http://simplythebest.net/scripts/DHT...cript_100.html[/color]
            >>[color=darkred]
            >> > Any thoughts would be most helpful.[/color]
            >>
            >> Without Javascript, not only does the menu not work, it doesn't even
            >> exist.[/color][/color]
            [color=blue]
            >Should I assume this means you have scripts disabled on your machine?
            >I'm not really sure what I need to do with this response since its
            >worked fine on every browser/computer I've tried it on.[/color]

            I've tried to explain it a bit in:


            --
            Stephen Poley


            Comment

            • Arne

              #7
              Re: tree menu in dhtml

              Stephen Poley skrev 2004-09-15 19:31:[color=blue]
              > On 15 Sep 2004 08:52:05 -0700, tuoni42@hotmail .com (Andromeda) wrote:
              >[color=green]
              >>Should I assume this means you have scripts disabled on your machine?
              >>I'm not really sure what I need to do with this response since its
              >>worked fine on every browser/computer I've tried it on.[/color]
              >
              > I've tried to explain it a bit in:
              > http://www.xs4all.nl/~sbpoley/webmatters/whatnojs.html[/color]

              A you say on your page Stephen, estimates vary how many visitors browse
              without Javascript. According to W3Schools
              (http://www.w3schools.com/browsers/browsers_stats.asp) 10% did it in
              July 2004. But the figures from different sites depends a lot according
              to what kind of visitors the site has.

              On a large part of popular sites it's not possible to do anything if you
              don't have Javascript enabled (shopping, game, entertainment etc). So
              those sites probably get almost 100% JS enabled in their stats :-)

              I truly belive most IE-users don't disable Javascript. That's because
              IE-users is in large majority on sites like those mentioned above. And
              it's not easy to changed in IE from disable to enable and back again
              within a couple of minutes an do the same thing all over again a few
              minutes later. With Mozilla that's easier :-)

              But I really recommend everybody not to use Javascript (and DHTML is
              mostly JS) on "critical" parts of the site, sutch as the menu. Not only
              because some visitors don't have JS enabled, but for som visitors the
              script may not work even if they have it on. For not critical things JS
              may be used. But an the other hand, is those not critical things useful
              at all?

              --
              /Arne

              Comment

              • Alan J. Flavell

                #8
                Re: tree menu in dhtml

                On Wed, 15 Sep 2004, Arne wrote:
                [color=blue]
                > I truly belive most IE-users don't disable Javascript.[/color]

                So do I; but eventually some of them are going to get tired of having
                their systems trashed for them. Maybe they'll find one of the web
                sites (including MS themselves) where disabling JS for untrusted sites
                is recommended.
                [color=blue]
                > it's not easy to changed in IE from disable to enable and back again
                > within a couple of minutes an do the same thing all over again a few
                > minutes later.[/color]

                But that's not the way to do it! Go to tools -> internet options ->
                security. Some of the settings are on the Custom dialog...

                One way is to define the security options for the Internet Zone -
                disabling JS - and for the Trusted Sites zone - where you enable JS.
                Then, when you meet a site that you're prepared to trust, and which
                needs JS, you put it into the Trusted sites zone. (Much the same for
                other kinds of client-side active content).

                Another way is to set the JS option to Prompt, so that any site that
                wants to use JS causes a popup dialog. Then you get to choose on a
                visit by visit basis. Note, by the way, that MS then comes up with a
                hopelessly anodyne warning: "Scripts are usually safe". Translation:
                "Scripts are sometimes dangerous, and occasionally can trash your
                system - are you sure this is worth it?".
                [color=blue]
                > With Mozilla that's easier :-)[/color]

                Indeed.
                [color=blue]
                > But I really recommend everybody not to use Javascript (and DHTML is
                > mostly JS) on "critical" parts of the site, sutch as the menu.[/color]

                If we're talking about web pages "per se" (and in the present thread I
                think we are), the key is not to *rely* on it for critical function.
                Use it, if you want to use it, for extra optional conveniences, and
                I'll make no objection. But ensure that the web page is functional
                without it.

                There are exceptions, (typically referred to as "web applications"),
                where the web "page" is really a kind of control panel for driving
                some complex system. In that case there may well be situations where
                JS, Java, and even other kinds of active content can be justified, if
                the task can't be sensibly undertaken without them. My example for
                this would be vrvs.org. But I consider those to be very much an
                exception, compared with the more normal kind of web page. And I
                trust those chaps not try causing mischief on my system.
                [color=blue]
                > Not only because some visitors don't have JS enabled, but for som
                > visitors the script may not work even if they have it on.[/color]

                Right. For example, indexing robots ;-)

                Comment

                • Brian

                  #9
                  Re: tree menu in dhtml

                  Arne wrote:
                  [color=blue]
                  > estimates vary how many visitors browse without Javascript. According
                  > to W3Schools (http://www.w3schools.com/browsers/browsers_stats.asp)
                  > 10% did it in July 2004.[/color]

                  www stats are never entirely reliable.
                  [color=blue]
                  > But the figures from different sites depends a lot according to what
                  > kind of visitors the site has.[/color]

                  Indeed. The one thing you can be sure of is that there are at least
                  *some* non-javascript user-agents that will visit your site. Since that
                  is a given, it naturally follows that you must design a site such that
                  javascript is not required, as Neal said.
                  [color=blue]
                  > On a large part of popular sites it's not possible to do anything if
                  > you don't have Javascript enabled (shopping, game, entertainment
                  > etc).[/color]

                  Large popular sites do lots of dumb things. I wouldn't recommend that
                  anyone copy them.
                  [color=blue]
                  > So those sites probably get almost 100% JS enabled in their stats :-)[/color]

                  Just one of the reasons why www stats are unreliable.
                  [color=blue]
                  > I truly belive most IE-users don't disable Javascript.[/color]

                  You can "truly believe" anything you like. But how will that change
                  anyone's mind here?
                  [color=blue]
                  > But I really recommend everybody not to use Javascript (and DHTML is
                  > mostly JS) on "critical" parts of the site, sutch as the menu. Not
                  > only because some visitors don't have JS enabled, but for som
                  > visitors the script may not work even if they have it on.[/color]

                  Exactly so.
                  [color=blue]
                  > For not critical things JS may be used. But an the other hand, is
                  > those not critical things useful at all?[/color]

                  Of course. Javascript form validation provides faster error prevention
                  help than the server side variety. A good form has both: js for a quick
                  response, server side for those without js. I've seen neat js scripts to
                  create pull quotes from a text with simple markup. No js? All that's
                  lost is the pull quotes; the text is unchanged. There are loads of
                  useful add-ons you can do with js. Check out comp.lang.javas cript for
                  more on this. Just be sure to note who has a clue, and who are the
                  "cowboys" (to steal Nick Kew's term) creating fragile scripts with no
                  useful fallback.

                  --
                  Brian (remove "invalid" to email me)

                  Comment

                  • Arne

                    #10
                    Re: tree menu in dhtml

                    This goes as a reply for both Alan and Brian, and forgive for leaving
                    out most of the quotes :-)

                    I totaly agree to what you say, but unfortunaly that don't change
                    anything about how the large majority of the (IE)users do and not do
                    when surfing.

                    You know what is the best way to do things, I know it to (i hope). And
                    so do a lot of others. Especially they who use other UA's than IE and
                    who use other OS's than Windows.

                    But the large majority is using Windows and still do it different. From
                    my personal experience, I know a great lot of them don't change the
                    default settings for security or almost everything else, have their OE
                    for HTML format for mail, don't even do much Windows Updates.

                    Brian said:[color=blue]
                    > Large popular sites do lots of dumb things. I wouldn't recommend that
                    > anyone copy them.[/color]

                    But still most of them do that. That's the main reason why the majority
                    don't disable JS. I don't like it, you don't like it, but it's the fact.
                    [color=blue]
                    > You can "truly believe" anything you like. But how will that change
                    > anyone's mind here?[/color]

                    My purpose was not to change anybodys mind here. I guess most of the
                    posters here can estimate from their experience, and I do it from mine.
                    From your experience, do you belive most IE-users disable Javascript?
                    We say they should disable, but that don't change anything since they
                    (most IE-users) are not even participating in this group.

                    Alan said:[color=blue]
                    > Maybe they'll find one of the web sites (including MS themselves)
                    > where disabling JS for untrusted sites is recommended.[/color]

                    I hope so. I did it long ago, and that was the time I found out that
                    changing browser and mail client was the best thing to do :-)

                    But I still see so many asking for help because they are struggling with
                    virus, adware, trojans etc. etc. But when they get clean, they continue
                    to use IE/OE in the same way they did earlier. And therefore they are
                    coming back asking for help, over and over again.
                    [color=blue]
                    > There are exceptions, (typically referred to as "web applications")[/color]

                    Yes, that's true. Now rule without exceptions :-)
                    But I must have really, really great interest (and trust) in a site that
                    says I *must* not only enable Java, but also Javascript, Cookies and
                    Pop-up windows in order to use their service. Java is one thing that I
                    always keep disabled.

                    And vrvs.org may be sutch a company, if I would need the kind of service
                    they provide. But first I would look at other options, if it's possible
                    to do what I want in a other way. :-)

                    I hope you understand that I agree with you how it should be. I just
                    don't belive it's so, and also wonder how it can be like it should :-)

                    --
                    /Arne

                    Comment

                    • Richard Cornford

                      #11
                      Re: tree menu in dhtml

                      Brian wrote:[color=blue]
                      > Arne wrote:[/color]
                      <snip>[color=blue][color=green]
                      >> But I really recommend everybody not to use Javascript
                      >> (and DHTML is mostly JS) on "critical" parts of the site,[/color][/color]

                      That seems a little extreme, and likely to be interpreted as a knee-jurk
                      reaction and the guidance possibly dismissed for that reason alone. I
                      don't see why there should be an inverse relationship between the
                      critical-ness of a part of a web site and the use of javascript, as
                      such. In the event of its inevitable failure in some environments a
                      well-designed browser script will facilitate fall-back (possibly to
                      server-side alternatives) or cleanly degrade, leaving the underlying
                      HTML as viable as it would be without the script. In that case it
                      doesn't matter how critical the page is, it won't be rendered non-viable
                      by the failure of the script.

                      The problem is that well-designed scripts are very much in the minority,
                      and in a world where ineptly authored 'copy-and-paste' scripts are
                      available in their thousands from scores of web sites, or listed as
                      examples in scripting books/web tutorials, or churned out by popular web
                      page authoring software, or posted to Usenet by individuals who haven't
                      yet seen (and may never see, or recognise) the issues.

                      Unfortunately, it takes time and effort to learn how to design and
                      program a decent browser scripts and there are only a relatively small
                      number of individuals who have made that effort, and (for technical
                      reasons related to the requirements of good script design) they are not
                      writing 'copy-and-paste' scripts.

                      While the apparent simplicity of javascript as a language, the absence
                      of a need for any special authoring software, followed by superficial
                      success in writing scripts ("worked fine on every browser/computer I've
                      tried it on" ( == default configurations of two or three browsers
                      exclusively on the Windows OS)), leaves many with sufficient confidence
                      in their scripting abilities that they start lumbering clients (and
                      other unsuspecting victims) with scripts that do needlessly screw-up
                      critical parts of web sites.

                      My formulation of the advice would be that anyone who cannot look at a
                      javascript source and see; when and where it will fail, why it will
                      fail, and (most importantly) how it will fail (in the sense of the
                      consequences of its failure), should not consider themselves qualified
                      to judge the script, or its suitability for inclusion on a public web
                      site (and especially any critical part of that site). And; if in doubt
                      seek qualified advice or leave the script alone.

                      <snip>[color=blue][color=green]
                      >> For not critical things JS may be used. But an the other hand, is
                      >> those not critical things useful at all?[/color]
                      >
                      > Of course. Javascript form validation provides faster error
                      > prevention help than the server side variety. A good form
                      > has both: js for a quick response, server side for those
                      > without js.[/color]

                      Part of the reason that server-side validation is not optional is that
                      even with a javascript enabled client what gets sent to the server may
                      still not have been validated (possibly deliberately), and there is
                      noting to that says HTTP requests can only originate with web browsers
                      anyway. The server is the only place where validation is 100% reliable.
                      [color=blue]
                      > I've seen neat js scripts to create pull quotes from a text
                      > with simple markup. No js? All that's lost is the pull quotes;
                      > the text is unchanged. There are loads of useful add-ons you
                      > can do with js. Check out comp.lang.javas cript for more on this.
                      > Just be sure to note who has a clue, and who are the "cowboys"
                      > (to steal Nick Kew's term) creating fragile scripts with no
                      > useful fallback.[/color]

                      The tree menu is one of the easier scripts to design for clean
                      degradation. The fragile scripts define the data for the menu in some
                      sort of javascript structure, so when they fail there is nothing at all
                      available to the user. A better strategy defines the data in the HTML,
                      usually as nested UL elements. That alone means that total failure (as
                      is inevitable when javascript is not enabled or available) leaves the
                      user with access to anything contained in the menu (along with search
                      engines and the like). The script then only has to verify that the
                      browser supports the features that would be needed, locate the UL
                      structure, and work through it changing its CSS and adding event
                      handlers to transform the ULs into the tree menu. If the scripts is
                      suitably cautions and leaves the HTML alone unless it is certain that
                      the scripted menu is viable, then you have a menu that will probably
                      work as well as the fragile script on the same browsers, but without
                      denying the user access to the basic functionality regardless of which
                      browser they use (or how they configure it).

                      Netscape 4 is not amenable to that strategy, and it is a
                      disproportionat e effort to actively support some less dynamic browsers
                      like Opera <= 6, but as the users of those browsers will still have
                      access to the underlying HTML they are no worse off than users who don't
                      have javascript at all and so can still use the page.

                      There remain issues that such a script still needs to address. Such as
                      keyboard navigation (required by WCAG 1.0) and how screen-readers
                      working with javascript enabled browsers will handle the dynamic
                      manipulation of the content.

                      Richard.


                      Comment

                      • Mark Parnell

                        #12
                        Re: tree menu in dhtml

                        On 15 Sep 2004 08:52:05 -0700, Andromeda <tuoni42@hotmai l.com> declared
                        in comp.infosystem s.www.authoring.html:
                        [color=blue]
                        > Should I assume this means you have scripts disabled on your machine?[/color]

                        Not usually, but you should always test under those conditions.
                        [color=blue]
                        > I'm not really sure what I need to do with this response since its
                        > worked fine on every browser/computer I've tried it on.[/color]

                        They all had Javascript enabled, then.

                        No statistics are ever totally accurate on the web, but most estimates
                        say between about 10-15% of people surf with scripting disabled. Using
                        navigation that relies on Javascript to function is therefore
                        effectively the same as shutting down the server on New Years Day and
                        not turning it back on until the second week of February.

                        Plus your site's potentially most important visitor, Googlebot, doesn't
                        support Javascript, therefore won't be able to follow the links to any
                        of the other pages on your site.

                        --
                        Mark Parnell

                        Comment

                        • Andromeda

                          #13
                          Re: tree menu in dhtml

                          I appreciate all the articles here, but none of these seem to answer
                          my original question.

                          And no, I am not new around here. No, I am not new to web authoring.
                          Yes, the site is functional without the menu. The site you are viewing
                          is not my site, it's only the place I found the script.

                          Comment

                          • Shawn K. Quinn

                            #14
                            Re: tree menu in dhtml

                            begin quote from Andromeda in
                            <c35615de.04091 42312.62ed72bd@ posting.google. com>:
                            [color=blue]
                            > I've been trying to add a tree menu to my website with some luck (more
                            > or less). I came across a script on simplythebest.n et, but I seem to
                            > be having a problem with it... and since they have no help section,
                            > this has brought me here.[/color]

                            This has nothing to do with HTML. "DHTML" actually refers to Javascript
                            (most of the time) or certain elements of CSS (most of the rest). So, maybe
                            ask in one of those groups, or the script author.

                            --
                            Shawn K. Quinn

                            Comment

                            • Andy Dingley

                              #15
                              Re: tree menu in dhtml

                              On Wed, 15 Sep 2004 18:40:22 GMT, Arne <arne@luras.n u> wrote:
                              [color=blue]
                              >I truly belive most IE-users don't disable Javascript.[/color]

                              True.

                              But are you still going to dump on the others ?


                              It's not about doing something for _most_ users, it's about thinking
                              how it works for _all_ users. It's OK to be restricted for some users
                              with the feature turned off, but you have to give them something.


                              How I do this is with a mix of CSS and maybe JS, but JS doesn't really
                              add much anyway.

                              Build a nested menu structure of <menu> or <ul>. On each <li> that
                              represents the current position, set the attribute class="current" .
                              Apart from the attribute, the entire menu structure can be duplicated
                              between pages, which makes content management easier ( I cut and
                              paste, then have a small Perl script that does the fixup for the
                              atribute)

                              In CSS, set top level <li> to be visible and child level <li><li> to
                              be hidden. Set the child level <li>s where they're "current" to be
                              visible.

                              More CSS to colour highlight the current meu path

                              Use a:hover or some JS rollovers to make child <li> pop-up when
                              they're rolled over and maybe hide the current path temporarily.



                              If you have all the bells and whistles, this is a dynamic menu,
                              whether you do it with CSS or JS.

                              If JS is turned off or the a:hover selectors don;t work, you can't nav
                              to "cousin" menu selections, but you can get there through the top
                              level and the "uncle" selection.

                              If CSS is entirely broken, the whole menu structure becomes visible.
                              This is probably ugly, but it still works.

                              --
                              Smert' spamionam

                              Comment

                              Working...