Javascript Magento:签出滚动到页面顶部

Javascript Magento:签出滚动到页面顶部,javascript,jquery,html,css,magento,Javascript,Jquery,Html,Css,Magento,我们遇到了一个问题,当下一步在单页签出中加载时,页面没有滚动到顶部 如果一个人在计费步骤中输入所有数据并单击“继续”按钮,则下一步将加载到页面的一半。基于上一步中的最后一个位置 我希望单页签出中的每一步都从页面顶部开始 我目前在opcheckout.js中得到了以下信息: gotoSection: function(section) { var sectionElement = $('opc-'+section); sectionElement.addClassName('all

我们遇到了一个问题,当下一步在单页签出中加载时,页面没有滚动到顶部

如果一个人在计费步骤中输入所有数据并单击“继续”按钮,则下一步将加载到页面的一半。基于上一步中的最后一个位置

我希望单页签出中的每一步都从页面顶部开始

我目前在opcheckout.js中得到了以下信息:

gotoSection: function(section)
{
    var sectionElement = $('opc-'+section);
    sectionElement.addClassName('allow');
    this.accordion.openSection('opc-'+section);
    this.reloadProgressBlock(section);
    jQuery("html, body").delay(10).animate({scrollTop: jQuery("#opc-"+section).offset().top }, 500);
},
但这并不奏效,因为我们使用固定的标题

那么,我该如何解决这个问题,使它进入页面的绝对顶部呢?

编辑的

我使用的是Magento 1.9.1.1,这是文件skin/frontend/rwd/default/js/opcheckout\u rwd.js的内容:

/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

Checkout.prototype.gotoSection = function (section, reloadProgressBlock) {
    // Adds class so that the page can be styled to only show the "Checkout Method" step
    if ((this.currentStep == 'login' || this.currentStep == 'billing') && section == 'billing') {
        $j('body').addClass('opc-has-progressed-from-login');
    }

    if (reloadProgressBlock) {
        this.reloadProgressBlock(this.currentStep);
    }
    this.currentStep = section;
    var sectionElement = $('opc-' + section);
    sectionElement.addClassName('allow');
    this.accordion.openSection('opc-' + section);

    // Scroll viewport to top of checkout steps for smaller viewports
    if (Modernizr.mq('(max-width: ' + bp.xsmall + 'px)')) {
        $j('html,body').animate({scrollTop: $j('#checkoutSteps').offset().top}, 800);
    }

    if (!reloadProgressBlock) {
        this.resetPreviousSteps();
    }
}

我没有你描述的问题。因此,我建议您更改包并使用rwd(这应该是自Magento 1.9.1以来的基本包)。您可以从此软件包开始构建新主题。

您使用的是哪个版本的Magento?我使用的是1.9.0.1版本的Hanks,但我不想使用单页签出。我想使用默认步骤签出。我更改了答案,现在看一看。