Page 1 of 1

How can I make checkout page scroll to top on postbacks?

Posted: Thu Oct 08, 2009 6:24 pm
by ZLA
I tried adding this code to the checkout conlib head section but it didn't change anything:

Code: Select all

<script type="text/javascript" language="javascript">window.scrollTo(0,0)</script>
Is there any way to have the page always start at the top?
Ideally, if there is a validation error, we'd want it to do the normal scroll to the validation summary and scroll to the top when there are no errors but scrolling to the top is more important.

I see there's the following code near the bottom of the page but I can't figure out how it's used. Based on some searches, I think it may be related to validation summary but it's not something I've come across before. Here's the code:

Code: Select all

<script type="text/javascript" language="javascript">window.scrollTo=function(x,y){return true;}</script>
Thanks in advance.

Re: How can I make checkout page scroll to top on postbacks?

Posted: Thu Oct 08, 2009 7:29 pm
by igavemybest
I am guessing the function has an x,y position on the page it is telling it to scroll to.Why dont you comment out the bottom and see if your code then works?

Re: How can I make checkout page scroll to top on postbacks?

Posted: Fri Oct 09, 2009 3:12 am
by jmestep
There is a DisableValidationScrollling in the App_Code/PageHelper.cs that you might be able to use or disable

Code: Select all

public static void DisableValidationScrolling(Page page)
    {
        //PREVENT SCROLL ON SUBMIT
        //DISABLE ALL JAVASCRIPT SCROLLING FOR THIS PAGE
        string script = "<script type=\"text/javascript\" language=\"javascript\">window.scrollTo=function(x,y){return true;}</script>";
        page.ClientScript.RegisterStartupScript(typeof(Page), "DisableValidationScrolling", script, false);
    }


Re: How can I make checkout page scroll to top on postbacks?

Posted: Fri Oct 09, 2009 6:27 am
by ZLA
Thank you Judy and igavemybest. Unfortunately, I was unable to get it to work. I tried commenting out DisableValidationScrolling. That stopped the scrolling when there was a validation error and the page refreshed to the top. But on postback, the page still refocussed to the middle. That's the reverse of what we want.

I still have no idea what is causing the scrolling on post back: javascript from AC code or inherent .NET code.

Able Commerce, I would appreciate it if you could point me in the right direction. Though our site is live, we can't do our grand opening until we get this resolved. Thank you.

Re: How can I make checkout page scroll to top on postbacks?

Posted: Fri Oct 09, 2009 7:02 am
by jmestep
Here is a post one of our guys made- maybe it would help.
viewtopic.php?f=42&t=12329

Re: How can I make checkout page scroll to top on postbacks?

Posted: Fri Oct 09, 2009 7:27 am
by ZLA
Thanks Judy. I'll look into that.