Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Max Edwards 26 posts 50 karma points
    Jul 20, 2010 @ 14:12
    Max Edwards
    0

    Contour resetting scroll bar to the top of the page when validating input

    I have a request from a client to stop a page jumping to the top of the page after a contour form fails validation.

    Does anyone know why it does this and how easy it might be to change this behaviour? It looks like the validation is done client-side.

    Thanks

  • Mads Krohn 211 posts 501 karma points c-trib
    Oct 17, 2010 @ 22:44
    Mads Krohn
    1

    Even though this is an old question I thought I might as well throw in the answer, as I was having the same problem recently. The page jumping is caused by the .NET validation functions and is a known bug/feature. Somewhere in the validation script is a call to window.scrollTo(0, 0) and that is what causes the jumping.

    A very quick workaround it to override the scrollTo function with an empty function on $(document).ready() or similar: window.scrollTo = function () { }

    Just be sure that there aren't any other scripts using that function, as they will fail as well. I have tried using the following code with great succes:

    window.originalScrollTo = window.scrollTo;
    window.scrollTo = function () { }

    Then I can still use the scrollTo functionality, however, the form validation wont make the page jump.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies