$(document).ready(function () { //解决iOS中伪类:active失效 document.body.addEventListener('touchstart', function () { }); //当弹窗出现时内容层禁止滚动 $("body").on("touchmove", function (event) { if ($("iframe").is(":visible") == true) { event.preventDefault(); } }) }); function scrollContent() { aler("111"); this.interval = setInterval(() => { this.scrollToEnd(); }, 500) } function scrollToEnd() { document.body.scrollTop = document.body.scrollHeight; } function clearSrcoll() { clearInterval(this.interval); } function on_off_hint() { if ($(".hint_shadow").attr("style") == "display:block") { hint = 0; $(".hint_shadow").attr("style", "display:none"); $(".hint_mian").attr("style", "display:none"); $('body').removeClass('hint_body');//去掉给body的类 $(window).scrollTop(top);//设置页面滚动的高度,如果不设置,关闭弹出层时页面会回到顶部。 } else { hint = 1; $(".hint_shadow").attr("style", "display:block"); $(".hint_mian").attr("style", "display:block"); top = $(window).scrollTop();//获取页面的scrollTop; $('body').css("top", -top + "px");//给body一个负的top值; $('body').addClass('hint_body');//给body增加一个类,position:fixed; } }