popups in javascript

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

    #1

    popups in javascript

    I've had a look through the archives but cannot find anything that
    really answers this so...

    I have a menu system composed of a series of "buttons" (actually span
    elements) that react to the usual onMouseOver; onMouseClick &
    onMouseOut events. I wish to have descriptive popups associated with
    each button that are shown using the onMouseOver event.

    Now I can do this with one caveat: if I scroll the page down and hover
    the mouse over a button, the popup appears, but it is in the same
    position as if I still had the top of the document visible. I.e. the
    popup appears in a fixed position with regards to the document origin
    rather than next to the button it describes. Is there any way to get
    around this so that the popup appears in its relative position with
    regards to the button rather than the page?

    TIA

    Bob
  • Richard Cornford

    #2
    Re: popups in javascript

    Bob Wightman wrote:[color=blue]
    > I've had a look through the archives but cannot find anything that
    > really answers this so...
    >
    > I have a menu system composed of a series of "buttons" (actually span
    > elements) that react to the usual onMouseOver; onMouseClick &
    > onMouseOut events. I wish to have descriptive popups associated with
    > each button that are shown using the onMouseOver event.
    >
    > Now I can do this with one caveat: if I scroll the page down and hover
    > the mouse over a button, the popup appears, but it is in the same
    > position as if I still had the top of the document visible. I.e. the
    > popup appears in a fixed position with regards to the document origin
    > rather than next to the button it describes. Is there any way to get
    > around this so that the popup appears in its relative position with
    > regards to the button rather than the page?[/color]

    Obviously you need to add the amount by which the page is scrolled
    vertically and horizontally to the top and left values respectively when
    you set them. See:-

    <URL: jibbering.com/faq/faq_notes/not_browser_det ect.html#bdScro ll >

    Richard.


    Comment

    • Steven Daedelus

      #3
      Re: popups in javascript

      In article <c979co$sdk$1$8 300dec7@news.de mon.co.uk>,
      "Richard Cornford" <Richard@litote s.demon.co.uk> wrote:
      [color=blue]
      > Bob Wightman wrote:[color=green]
      > > I've had a look through the archives but cannot find anything that
      > > really answers this so...
      > >
      > > I have a menu system composed of a series of "buttons" (actually span
      > > elements) that react to the usual onMouseOver; onMouseClick &
      > > onMouseOut events. I wish to have descriptive popups associated with
      > > each button that are shown using the onMouseOver event.
      > >
      > > Now I can do this with one caveat: if I scroll the page down and hover
      > > the mouse over a button, the popup appears, but it is in the same
      > > position as if I still had the top of the document visible. I.e. the
      > > popup appears in a fixed position with regards to the document origin
      > > rather than next to the button it describes. Is there any way to get
      > > around this so that the popup appears in its relative position with
      > > regards to the button rather than the page?[/color]
      >
      > Obviously you need to add the amount by which the page is scrolled
      > vertically and horizontally to the top and left values respectively when
      > you set them. See:-
      >
      > <URL: jibbering.com/faq/faq_notes/not_browser_det ect.html#bdScro ll >
      >
      > Richard.[/color]

      IIRC, position:absolu te positions elements relative to their enclosing
      box. Confusing but true. So if your rollovers are inside a span, you can
      position the popups relative to that span by putting the code inside the
      span tags and specifying position:aboslu te, plus whatever offsets you
      want.

      You could also position the popups relative to the mouse, I believe...

      Comment

      • Lee

        #4
        Re: popups in javascript

        Bob Wightman said:[color=blue]
        >
        >I've had a look through the archives but cannot find anything that
        >really answers this so...
        >
        >I have a menu system composed of a series of "buttons" (actually span
        >elements) that react to the usual onMouseOver; onMouseClick &
        >onMouseOut events. I wish to have descriptive popups associated with
        >each button that are shown using the onMouseOver event.
        >
        >Now I can do this with one caveat: if I scroll the page down and hover
        >the mouse over a button, the popup appears, but it is in the same
        >position as if I still had the top of the document visible. I.e. the
        >popup appears in a fixed position with regards to the document origin
        >rather than next to the button it describes. Is there any way to get
        >around this so that the popup appears in its relative position with
        >regards to the button rather than the page?[/color]

        Another simple option is to position the popup relative to the
        pointer, which you can obtain from the onmouseover event.

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: popups in javascript

          Steven Daedelus wrote:
          [color=blue]
          > In article <c979co$sdk$1$8 300dec7@news.de mon.co.uk>,
          > "Richard Cornford" <Richard@litote s.demon.co.uk> wrote:[/color]

          Please don't write attribution novels, see
          <http://netmeister.org/news/learn2quote.htm l>
          [color=blue]
          > IIRC, position:absolu te positions elements relative to their enclosing
          > box. [...][/color]

          It doesn't. position:absolu te positions elements relative to their next
          ancestor that is positioned absolute or, if there is none, to the viewport.


          PointedEars

          Comment

          • Ron

            #6
            Re: popups in javascript

            Thomas 'PointedEars' Lahn wrote:[color=blue][color=green]
            >>In article <c979co$sdk$1$8 300dec7@news.de mon.co.uk>,
            >> "Richard Cornford" <Richard@litote s.demon.co.uk> wrote:
            >>IIRC, position:absolu te positions elements relative to their enclosing
            >>box. [...][/color]
            >
            >
            > It doesn't. position:absolu te positions elements relative to their next
            > ancestor that is positioned absolute or, if there is none, to the viewport.[/color]

            Heya Thomas,
            According to the W3C recommendation, position:absolu te positions
            elements relative to the nearest ancestor that is not positioned
            "static". I've used position:relati ve several times in the past in order
            to use position:absolu te on a descendent without having to explicitly
            position its container relative to the viewport. Of course, I test
            mostly in Mozilla, so I'm not sure whether IE does the same.
            Reference: http://www.w3.org/TR/CSS21/visudet.h...-block-details

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: popups in javascript

              Ron wrote:[color=blue]
              > Thomas 'PointedEars' Lahn wrote:[color=green][color=darkred]
              >>>In article <c979co$sdk$1$8 300dec7@news.de mon.co.uk>,
              >>> "Richard Cornford" <Richard@litote s.demon.co.uk> wrote:
              >>>IIRC, position:absolu te positions elements relative to their enclosing
              >>>box. [...][/color][/color][/color]

              You seem to have confused the quotation levels.
              [color=blue][color=green]
              >> It doesn't. position:absolu te positions elements relative to their next
              >> ancestor that is positioned absolute or, if there is none, to the viewport.[/color]
              >
              > Heya Thomas,[/color]

              Please stop that. This is a public newsgroup, not private e-mail.
              [color=blue]
              > According to the W3C recommendation, position:absolu te positions
              > elements relative to the nearest ancestor that is not positioned
              > "static".[/color]

              Indeed.
              [color=blue]
              > [...] Of course, I test mostly in Mozilla, so I'm not sure whether
              > IE does the same.
              > Reference: http://www.w3.org/TR/CSS21/visudet.h...-block-details[/color]

              I have tested with Mozilla/5.0 for Windows as well and they follow the spec
              in this regard. IE 6 for Windows does follow it, too. Thanks for pointing
              this out. However, do not cite CSS 2.1 as a reference, it is still only a CR:

              | Publication as a Candidate Recommendation does not imply endorsement by
              | the W3C Membership. It is inappropriate to cite this document as other
              | than work in progress.

              Cite CSS2 instead which states the case as well:

              <http://www.w3.org/TR/CSS2/visudet.html#co ntaining-block-details>


              PointedEars

              Comment

              • Steven Daedelus

                #8
                Re: popups in javascript

                In article <40B8E601.90609 08@PointedEars. de>,
                Thomas 'PointedEars' Lahn <PointedEars@nu rfuerspam.de> wrote:
                [color=blue]
                > Ron wrote:[color=green]
                > > Thomas 'PointedEars' Lahn wrote:[color=darkred]
                > >>>In article <c979co$sdk$1$8 300dec7@news.de mon.co.uk>,
                > >>> "Richard Cornford" <Richard@litote s.demon.co.uk> wrote:
                > >>>IIRC, position:absolu te positions elements relative to their enclosing
                > >>>box. [...][/color][/color]
                >
                > You seem to have confused the quotation levels.
                >[color=green][color=darkred]
                > >> It doesn't. position:absolu te positions elements relative to their next
                > >> ancestor that is positioned absolute or, if there is none, to the viewport.[/color]
                > >
                > > Heya Thomas,[/color]
                >
                > Please stop that. This is a public newsgroup, not private e-mail.[/color]

                Chill. This is a public newsgroup, not a courtroom.

                Comment

                Working...