scrollTo(x,y) problem; doesn't work with window.onload

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ManWithNoName
    New Member
    • Aug 2007
    • 88

    scrollTo(x,y) problem; doesn't work with window.onload

    This is my first post, so be gentle.

    This:

    [CODE=javascript]<body onload="window. scrollTo(x,y)">[/CODE]

    Works fine.

    This:

    [CODE=javascript]window.onload = function() { window.scrollTo (x,y) }[/CODE]

    Doesn't work at all.

    Why?
    Last edited by pbmods; Aug 28 '07, 06:14 PM. Reason: Changed [CODE] to [CODE=javascript].
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by ManWithNoName
    This is my first post, so be gentle.

    This:

    Code:
    <body onload="window.scrollTo(x,y)">
    Works fine.

    This:

    Code:
    window.onload = function() { window.scrollTo(x,y) }
    Doesn't work at all.

    Why?
    Welcome to TSDN.
    What is x and y in the first expression.
    [code=html]
    <form onload = "window.scrollT o(x,y)">
    <!--Here x and y would be number just you using variables-->
    [/code]

    You got my point?

    Kind regards,
    Dmjpro.

    Comment

    • ManWithNoName
      New Member
      • Aug 2007
      • 88

      #3
      Welcome to TSDN.
      Thanks for the warm welcome.

      What is x and y in the first expression.
      0,50

      You got my point?
      Actually... No. :)

      Well, it's not important any more. It works now, I do not know why, the code is exactly the same. This. Is. Soooo. Annoying.

      This is related to a more advanced XhttpRequest situation, I thought I had isolated the problem to this (window.onload Vs. body onload) but it's seems that I was to hasty in my judgement.

      I need to do some further testing to see where the problem is located...

      Anyhow, thanks for your input.

      Comment

      • ManWithNoName
        New Member
        • Aug 2007
        • 88

        #4
        ... How do I mark this thread resolved?

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          Originally posted by ManWithNoName
          Welcome to TSDN.
          Thanks for the warm welcome.

          What is x and y in the first expression.
          0,50

          You got my point?
          Actually... No. :)

          Well, it's not important any more. It works now, I do not know why, the code is exactly the same. This. Is. Soooo. Annoying.

          This is related to a more advanced XhttpRequest situation, I thought I had isolated the problem to this (window.onload Vs. body onload) but it's seems that I was to hasty in my judgement.

          I need to do some further testing to see where the problem is located...

          Anyhow, thanks for your input.
          Sorry for Misunderstandin g your Problem.
          Anyway I also tried but the second one is problem.


          Kind regards,
          Dmjpro.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by ManWithNoName
            ... How do I mark this thread resolved?
            There's nothing in place to do that yet (and may never be because of possible problems).

            Comment

            • ManWithNoName
              New Member
              • Aug 2007
              • 88

              #7
              Sorry for Misunderstandin g your Problem.
              Anyway I also tried but the second one is problem.


              That's OK, most of my problems are weird, thanks for trying.

              ()()()()()()()( )()()()()()()() ()()()()()()()( )()()()()()()() ()()()()()()()( )()()()()()()() ()()()()

              Originally posted by acoder
              There's nothing in place to do that yet (and may never be because of possible problems).
              I'm almost afraid to ask... But "possible problems"?.

              Comment

              • dmjpro
                Top Contributor
                • Jan 2007
                • 2476

                #8
                Originally posted by ManWithNoName
                ... How do I mark this thread resolved?
                And what's the Solution?

                Kind regards,
                Dmjpro.

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Originally posted by ManWithNoName
                  I'm almost afraid to ask... But "possible problems"?.
                  Well, you're good enough to say that your problem is resolved and want to mark it as such. Most don't. In fact, they might just disappear. That would then be up to the moderator to decide whether a question is resolved or not which is subjective. In this way, we could have a lot of unresolved questions. It also means more work for the mods.

                  Comment

                  • ManWithNoName
                    New Member
                    • Aug 2007
                    • 88

                    #10
                    I think I have isolated the problem now...

                    It seems to be a CSS issue (when CSS is removed it works as should).

                    Looking into to it...

                    Comment

                    • ManWithNoName
                      New Member
                      • Aug 2007
                      • 88

                      #11
                      Originally posted by dmjpro
                      And what's the Solution?

                      Kind regards,
                      Dmjpro.
                      The solution is that there isn't any problem with the window.onload function.
                      Last edited by ManWithNoName; Aug 28 '07, 12:06 PM. Reason: I see dead Posts

                      Comment

                      • ManWithNoName
                        New Member
                        • Aug 2007
                        • 88

                        #12
                        Originally posted by acoder
                        Well, you're good enough to say that your problem is resolved and want to mark it as such. Most don't. In fact, they might just disappear. That would then be up to the moderator to decide whether a question is resolved or not which is subjective. In this way, we could have a lot of unresolved questions. It also means more work for the mods.
                        (Ops, I accidentally pushed the report button when I wanted to press reply, I hope that I didn't cause any problems (I quickly stopped the submit process))

                        I see... There is however a certain satisfaction in being able to put a "you won't be hunting me in my restless dreams now-stamp" on your question.

                        I suppose I just got domesticated in forums using such a function...

                        Btw, suggestion for your forum: move the report button away from the reply button. Besides for the problem of mistakenly pushing it (I wonder who would do such a stupid mistake, anyway) it kind of feels a little bit tempting...
                        Last edited by ManWithNoName; Aug 28 '07, 12:14 PM. Reason: loadig..

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #13
                          Originally posted by ManWithNoName
                          (Ops, I accidentally pushed the report button when I wanted to press reply, I hope that I didn't cause any problems (I quickly stopped the submit process))
                          No, as long as you didn't submit, it's fine.
                          Originally posted by ManWithNoName
                          I see... There is however a certain satisfaction in being able to put a "you won't be hunting me in my restless dreams now-stamp" on your question.
                          I guess there is! There's pros and cons to this; you never know, it may well be added in the future.
                          Originally posted by ManWithNoName
                          Btw, suggestion for your forum: move the report button away from the reply button. Besides for the problem of mistakenly pushing it (I wonder who would do such a stupid mistake, anyway) it kind of feels a little be tempting...
                          Yes, this has already been suggested and I agree. Add any more suggestions and comments in the Feedback forum.

                          Comment

                          • ManWithNoName
                            New Member
                            • Aug 2007
                            • 88

                            #14
                            Originally posted by acoder
                            Add any more suggestions and comments in the Feedback forum.
                            Got you.

                            =============== =============== ==========

                            Anyway, like I said: I found what the problem was and have started a new thread.

                            The solution to this thread was that here simply wasn't anything wrong with window.onload scrollTo.

                            Comment

                            • pbmods
                              Recognized Expert Expert
                              • Apr 2007
                              • 5821

                              #15
                              Heya, NoName.

                              Did you mean document.unload ?

                              My guess is that window.unload() doesn't fire until the current document has been unloaded, which would mean that there's nothing to scroll to.

                              Comment

                              Working...