Loading ...
Sorry, an error occurred while loading the content.

Re: [OLmws] Controlling scrolling using the MODALSCROLL setting

Expand Messages
  • Foteos Macrides
    Patrick, The MODAL popups involve a number of hairy workarounds for bizarre behavior across the supported browsers in their handling of overflow settings
    Message 1 of 5 , Nov 27, 2007
    • 0 Attachment
      Patrick,
       
      The MODAL popups involve a number of hairy workarounds for bizarre behavior across the supported browsers in their handling of overflow settings applied to the documentElement (for modern browsers, that's the overall encasing html element) to eliminate and then restore the scroll bars for the overall document (as opposed to a child element such as a div).  It sounds as though you are describing the behavior of Firefox through its version 2.0.0.10, which is buggy such that when its document.documentElement.style.overflow is set to 'hidden', not only are the scroll bars eliminated, but the document inappropriately scrolls to the top.  I deal with that by saving the coordinates for the scrolled position of the overall document when the MODAL popup is invoked, and restoring them when the popup is closed and the MODAL block is lifted.  The Firefox bug is fixed in the developers' code recently released as Firefox 3beta1 (and should stay fixed in the formal Firefox 3.0 release scheduled for early 2008), but we'll still need overlibmws code which works for browsers with or without that bug.  The new MODALSCROLL command eliminates the setting of overflow to 'hidden' (so that the overall document's scroll bars persist), and thus also eliminates the inappropriate scroll to the top upon popup invocation in Firefox.  But the purpose of MODALSCROLL is to deal with MODAL popups whose height (or width) is likely to be greater than the height (or width) of the browser's current viewport, i.e., so that you can scroll the overall document (vertically or horizontally) to see the parts of the popup which extend beyond the viewport when the popup is invoked.  Since your MODAL popup is a presumably small "confirm dialog box" emulation, I'm not sure I follow why you added MODALSCROLL.  Perhaps you wanted to be sure Firefox users always will be able to see the section of the document (now under the semi-transparent modal shield) which would be deleted if the 'ok' button is chosen.  When MODALSCROLL is used, I still save the coordinates of the document's scrolled position when the popup is invoked and restore it when the popup is closed, because any scrolling of the document typically would have been to see portions of the popup that initially extended beyond the viewport, not to view another portion of the underlying document.  The demonstration of MODALSCROLL in the:
       
       
      support document is for a popup which is sure to exceed the viewport height, but I also tested MODALSCROLL with small popups which don't, and it behaves as intended, without any spurious document scroll to the top (i.e., unless the document was at the top when the MODAL popup was invoked) for any of the supported browsers.
       
      So... would it be possible for you to provide a URL for a test document which exhibits the problem, and indicate in which browser(s) it occurs, so that we can try to figure out where the problem lies and how we might deal with it?
       
      Fote
      --
       
      ----- Original Message -----
      Sent: Tuesday, November 27, 2007 10:28 PM
      Subject: [OLmws] Controlling scrolling using the MODALSCROLL setting

      Hi there
      I'm using the modal popup to display a 'confirm delete' message with  'ok' and 'cancel' buttons, and have just picked up the latest version to use the new MODALSCROLL setting.

      I have a long page with a table of data, and each row has a delete button. Before MODALSCROLL if I scrolled down the list and clicked delete the page would scroll to the top and the modal popup would appear.

      I've added MODALSCROLL now, and when I click the delete button the page stays where it is, but if I click 'cancel' (which calls cClick()) the popup disappears and the pages then scrolls back to the top.

      Is there anyway to stop this scrolling?

      I'm using an OLgetAJAX call to generate the content for the popup by the way.

      Many thanks,
      Patrick
    • Foteos Macrides
      ... Patrick, It just occurred to me that this problem might be due to your cancel button using just: cClick(); instead of: return cClick(); or
      Message 2 of 5 , Nov 28, 2007
      • 0 Attachment
        > I've added MODALSCROLL now, and when I
        > click the delete button the page stays where it is,
        > but if I click 'cancel' (which calls cClick()) the popup
        > disappears and the page then scrolls back to the top.
         
        Patrick,
         
        It just occurred to me that this problem might be due to your 'cancel' button using just:
         
        "cClick();"
         
        instead of:
         
        "return cClick();"
        or
        "cClick();return false;"
         
        when you also are using "#" instead of "javascript:void(0);" for your href or action.  That would cause the document to be displayed at 0,0 instead of the intended scrolled position.
         
        If that's not it, and you can't provide a public access URL for a test document which shows the problem, to debug it yourself you want to watch what is happening to the OLmScLeft and OLmScTop globals in overlibmws_modal.js.
         
        Fote
        --
         
      • Patrick Wilkes
        Thank you, indeed that has solved the problem. Many thanks for spotting it! I have to admit I don t really understand what is happening when you use href= #
        Message 3 of 5 , Nov 28, 2007
        • 0 Attachment
          Thank you, indeed that has solved the problem. Many thanks for
          spotting it! I have to admit I don't really understand what is
          happening when you use href="#" compared with
          href="javascript:void(0)" - I will find out!!

          Patrick

          --- In overlibmws@yahoogroups.com, "Foteos Macrides" <fote@...> wrote:
          >
          > > I've added MODALSCROLL now, and when I
          > > click the delete button the page stays where it is,
          > > but if I click 'cancel' (which calls cClick()) the popup
          > > disappears and the page then scrolls back to the top.
          >
          >
          > Patrick,
          >
          > It just occurred to me that this problem might be due to your
          'cancel' button using just:
          >
          > "cClick();"
          >
          > instead of:
          >
          > "return cClick();"
          > or
          > "cClick();return false;"
          >
          > when you also are using "#" instead of "javascript:void(0);" for
          your href or action. That would cause the document to be displayed at
          0,0 instead of the intended scrolled position.
          >
          > If that's not it, and you can't provide a public access URL for a
          test document which shows the problem, to debug it yourself you want
          to watch what is happening to the OLmScLeft and OLmScTop globals in
          overlibmws_modal.js.
          >
          > Fote
          > --
          >
        • Foteos Macrides
          Patrick, The # as an href or action value resolves to an instruction to jump to an undefined anchor in the current document, and thus causes a jump to the
          Message 4 of 5 , Nov 28, 2007
          • 0 Attachment
            Patrick,
             
            The "#" as an href or action value resolves to an instruction to jump to an undefined anchor in the current document, and thus causes a jump to the top of the current document.  It was recommended in the early days of javascript as a way to have the browser "do nothing" when onclick attempts to invoke javascript but the browser does not support javascript or has it disabled.  That was a misguided recommendation.  If you instead use "javascript:void(0);" that in effect means "do nothing whether or not the browser has javascript enabled" and is what you really want.  If the onclick ultimately returns false (and javascript is enabled), neither href or action value will be used, but otherwise it will be, and you want the value which really does nothing.
             
            Fote
            --
             
            ----- Original Message -----
            Sent: Wednesday, November 28, 2007 5:15 PM
            Subject: Re: [OLmws] Controlling scrolling using the MODALSCROLL setting

            Thank you, indeed that has solved the problem. Many thanks for spotting it! I have to admit I don't really understand what is happening when you use href="#" compared with href="javascript:void(0)" - I will find out!!
            [snip]
          Your message has been successfully submitted and would be delivered to recipients shortly.