Tree gets scrolled back to top upon refresh

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

    Tree gets scrolled back to top upon refresh

    I have an annoyîng problem with a javascript tree. When you scroll
    down to the bottom of the tree and click to open a node the tree is
    refreshed and scrolls back to the top, hiding the node. Is there a way
    to prevent the page from being scrolled back to the top on every
    refresh? Thank you for your help.
  • RobG

    #2
    Re: Tree gets scrolled back to top upon refresh

    Sergio Millich wrote:[color=blue]
    > I have an annoyîng problem with a javascript tree. When you scroll
    > down to the bottom of the tree and click to open a node the tree is
    > refreshed and scrolls back to the top, hiding the node. Is there a way
    > to prevent the page from being scrolled back to the top on every
    > refresh? Thank you for your help.[/color]

    If you post a brief example, you may get an answer more quickly. I'm
    not quite sure what you mean by a "javascript tree" - I presume you are
    talking about collapsible, hierarchical menus - but I may be wrong.

    Rob.

    Comment

    • Sergio Millich

      #3
      Re: Tree gets scrolled back to top upon refresh

      RobG <rgqld@iinet.ne t.auau> wrote in message news:<htXcd.219 9$aA.72544@news .optus.net.au>. ..[color=blue]
      > Sergio Millich wrote:[color=green]
      > > I have an annoyîng problem with a javascript tree. When you scroll
      > > down to the bottom of the tree and click to open a node the tree is
      > > refreshed and scrolls back to the top, hiding the node. Is there a way
      > > to prevent the page from being scrolled back to the top on every
      > > refresh? Thank you for your help.[/color]
      >
      > If you post a brief example, you may get an answer more quickly. I'm
      > not quite sure what you mean by a "javascript tree" - I presume you are
      > talking about collapsible, hierarchical menus - but I may be wrong.
      >
      > Rob.[/color]

      Is is in fact a tree that could be used as a menu or to navigate
      through folders in Explorer style, it is indeed collapsible. The main
      point is that as it expands in the frame so it has to be scrollable.
      The source code snippet wouldn't be meaningful because it is embedded
      in JSPs, here's what I have in the page:
      <script language="JavaS cript">function
      setTreeParamsAn dGo7129984(acti on, nodeId)
      {setFieldValue( 'cti_current_co ntexte', 'GC_LOISFED.'); go('/envirolex'
      + action + '?requestURI=%2 Fenvirolex%2Fui %2FEnvUiLoisFed .jsp%23tree7129 984&nodeId='
      + nodeId, false);}</script>
      <a name="tree71299 84"></a>
      <span class="tree"><u l>
      <li><a class="treeActu ator"
      href="javascrip t:setTreeParams AndGo7129984('/fermerNoeud.do' ,'242');"><span
      class="treeNode OpenCH">&nbsp;</a><a class="treeActu ator"
      title="Numéro: RS 101"
      href="javascrip t:setTreeParams AndGo7129984('/selectionnerNoe ud.do','242');" >CONSTITUTION
      FEDERALE</a></span><span><a
      href="http://www.admin.ch/ch/f/rs/101/index.html"> @ </a></span>
      etc...
      Pretty meaningless if you don't know what the functions do.
      What interests me is how to control the scrolling part. Thank you for
      your answers.

      Sergio.

      Comment

      • Michael Winter

        #4
        Re: Tree gets scrolled back to top upon refresh

        On 19 Oct 2004 03:30:59 -0700, Sergio Millich <millichs@iprol ink.ch> wrote:

        [snip]
        [color=blue]
        > <script language="JavaS cript">[/color]

        The language attribute has been deprecated for many years now in favour of
        the (required) type attribute.

        <script type="text/javascript">

        [reformatted:][color=blue]
        > function setTreeParamsAn dGo7129984(acti on, nodeId) {
        > setFieldValue(' cti_current_con texte', 'GC_LOISFED.');
        > go('/envirolex'
        > + action
        > + '?requestURI=%2 Fenvirolex%2Fui %2FEnvUiLoisFed .jsp%23tree7129 984&nodeId='
        > + nodeId, false);
        > }[/color]

        It would seem to me that the go function call reloads the page containing
        the menu. That's why it scrolls.
        [color=blue]
        > <a name="tree71299 84"></a>[/color]

        Though this anchor does exist, it may be ignored as it is empty. It would
        probably be better to give the target an id with that value.
        [color=blue]
        > <span class="tree"><u l>[/color]

        This is invalid mark-up. A SPAN element, which is inline, cannot contain a
        UL, which is block-level. You should validate your HTML
        (<URL:http://validator.w3.or g/>).

        [snip]
        [color=blue]
        > <a class="treeActu ator"
        > href="javascrip t: [...] ">[/color]

        You might want to read the FAQ (<URL:http://jibbering.com/faq/>),
        especially section 2.24.

        [snip]

        Hope that helps,
        Mike

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail.

        Comment

        • Fred Oz

          #5
          Re: Tree gets scrolled back to top upon refresh

          Sergio Millich wrote:[color=blue]
          > RobG <rgqld@iinet.ne t.auau> wrote in message news:<htXcd.219 9$aA.72544@news .optus.net.au>. ..[/color]
          [color=blue][color=green]
          >> If you post a brief example, you may get an answer more quickly. I'm
          >> not quite sure what you mean by a "javascript tree" - I presume you are
          >> talking about collapsible, hierarchical menus - but I may be wrong.
          >>
          >> Rob.[/color]
          >
          >
          > Is is in fact a tree that could be used as a menu or to navigate
          > through folders in Explorer style, it is indeed collapsible. The main
          > point is that as it expands in the frame so it has to be scrollable.
          > The source code snippet wouldn't be meaningful because it is embedded[/color]

          [snip]
          [color=blue]
          > Pretty meaningless if you don't know what the functions do.
          > What interests me is how to control the scrolling part. Thank you for
          > your answers.
          >
          > Sergio.[/color]

          Here are some code posted recently that shows collapsible menus, is
          this something like what you are trying to do? These are designed to
          work whether the user has JavaScript enabled or not.

          Just put some <a> tags into the ends of the branches to get working
          menus - follow the bottom branch.

          Rob.

          <html>
          <head>
          <script type="text/javascript">
          function mClick(n) {
          while (n.nodeName != 'LI' && n.nodeName != 'UL') {
          n = n.parentNode;
          }
          var n0 = n;
          while (n.nodeName != 'UL') {
          n = n.parentNode;
          }
          var o = n.childNodes;
          for (var i=0; i<o.length; ++i) {
          if (0[i] != n0) hideUL(o[i]);
          }
          for (var k=0; k<n0.childNodes .length; ++k) {
          if (n0.childNodes[k].style) n0.childNodes[k].style.display= '';
          }
          }
          function hideUL(x) {
          if (x.nodeName == 'UL') x.style.display ='none';
          for (var j=0; j<x.childNodes. length; ++j) {
          hideUL(x.childN odes[j]);
          }
          }
          function resetMenu() {
          mClick(document .getElementById ("menu0"));
          }
          </script>
          </head>
          <body>
          <!-- Menus start here -->
          <ul id="menu0">
          <li><a href="#" onclick="mClick (this)">menu 0 Level 0</a>
          <ul id="menu1">
          <li><a href="#"
          onclick="mClick (this)">menu 0 Level 0 Level 0</a>
          <ul>
          <li>menu 0 Level 0 Level 0 Level 0</li>
          <li>menu 0 Level 0 Level 0 Level 1</li>
          <li><a href="#"
          onclick="resetM enu();
          ">menu 0 Level 0 Level 0 Level 2</a></li>
          </ul
          </li>

          <li><a href="#"
          onclick="mClick (this)">menu 0 Level 0 Level 1</a>
          <ul>
          <li>menu 0 Level 0 Level 1 Level 0</li>
          <li>menu 0 Level 0 Level 1 Level 1</li>
          <li>menu 0 Level 0 Level 1 Level 2</li>
          </ul
          </li>
          </ul>
          </li>
          <li><a href="#" onclick="mClick (this)">menu 0 Level 1</a>
          <ul>
          <li><a href="#"
          onclick="mClick (this)">menu 0 Level 1 Level 0</a>
          <ul>
          <li>menu 0 Level 1 Level 0 Level 0</li>
          <li>menu 0 Level 1 Level 0 Level 1</li>
          <li>menu 0 Level 1 Level 0 Level 2</li>
          </ul
          </li>
          <li><a href="#"
          onclick="mClick (this)">menu 0 Level 1 Level 1</a>
          <ul>
          <li><a
          href="http://www.apple.com"[color=blue]
          >Apple</a></li>[/color]
          <li><a
          href="http://www.sun.com"[color=blue]
          >Sun</li>[/color]
          <li><a
          href="http://www.mozilla.org "[color=blue]
          >Mozilla</li>[/color]
          </ul
          </li>
          </ul>
          </li>
          </ul>
          <script type="text/javascript">

          resetMenu();
          </script>

          <!-- Menus end here -->

          </body>
          </html>

          Comment

          Working...