[英]Windows Phone 8 IE scrollTo not working
我有一些JavaScript,我正在關閉屏幕。 作為它的一部分,我希望頁面滾動到頂部,所以我使用的是window.scrollTo(0, 0)
,它可在android和iphone瀏覽器上使用,但Windows 8手機無法滾動...
var dismissWelcome;
dismissWelcome = function(e) {
var welcome;
if (((e != null ? e.stopPropagation : void 0) != null) && ((e != null ? e.preventDefault : void 0) != null)) {
e.stopPropagation();
e.preventDefault();
}
welcome = document.getElementById('welcome');
welcome.style.display = 'none';
window.scrollTo(0, 0);
};
addEvent('dismiss-welcome', 'touchstart', dismissWelcome);
我如何才能在Windows 8手機(最好是所有已知設備)上使用window.scrollTo(0, 0)
)。
我將其設置為超時,並且效果很好。 必須與被刪除的dom對象有關。 可能還有其他方法,但這對我來說很好。
var dismissWelcome;
dismissWelcome = function(e) {
var welcome;
if (((e != null ? e.stopPropagation : void 0) != null) && ((e != null ? e.preventDefault : void 0) != null)) {
e.stopPropagation();
e.preventDefault();
}
welcome = document.getElementById('welcome');
welcome.style.display = 'none';
window.scrollTo(0, 0);
// do it again, after the welcome page has finished being removed...
setTimeout(function() {
window.scrollTo(0, 0);
}, 200);
};
addEvent('dismiss-welcome', 'touchstart', dismissWelcome);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.