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

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

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

Post by ZLA » Thu Oct 08, 2009 6:24 pm

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.

User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

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

Post by igavemybest » Thu Oct 08, 2009 7:29 pm

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?

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

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

Post by jmestep » Fri Oct 09, 2009 3:12 am

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);
    }

Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

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

Post by ZLA » Fri Oct 09, 2009 6:27 am

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.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

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

Post by jmestep » Fri Oct 09, 2009 7:02 am

Here is a post one of our guys made- maybe it would help.
viewtopic.php?f=42&t=12329
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

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

Post by ZLA » Fri Oct 09, 2009 7:27 am

Thanks Judy. I'll look into that.

Post Reply