【发布时间】:2020-05-11 23:57:28
【问题描述】:
我在我的网站上使用magnific popups。当我单击图像时,它会在弹出窗口中调用另一个(第二个)html 页面,并且效果很好。
我的问题是,当弹出窗口打开时,我想使用以下代码将第二页滚动到顶部:
window.scrollBy(0, 0);
但它不起作用。它将后面的内容滚动到顶部。
我想将第二个 html 页面滚动到弹出窗口内的顶部。
我该怎么做? 这是我在第二个 html 中的代码:
$('.accordion a').click(function(j) {
//window.scrollTo(0, 0);
//document.getElementById(aa).onload = function(){ this.contentWindow.scrollBy(0,0);};
//window.parent.scrollTo(0,0);
//this.contentWindow.scrollTo(0,0);
var dropDown = $(this).closest('li').find('p');
$(this).closest('.accordion').find('p').not(dropDown).slideUp();
if ($(this).hasClass('active')) {
$(this).removeClass('active');
} else {
$(this).closest('.accordion').find('a.active').removeClass('active');
$(this).addClass('active');
}
dropDown.stop(false, true).slideToggle();
j.preventDefault();
});
【问题讨论】: