參考 感謝分享
案例頁面:view-source:
第一步:給body加上個css類別樣式
body.modal-open
第二部:建立核心函式:
/*** modalhelper helpers resolve the modal scrolling issue on mobile devices
* * requires document.scrollingelement polyfill
*/var modalhelper = (function(bodycls) ,
//關閉彈窗
beforeclose: function()
};})('modal-open');
第三部:開啟/關閉彈窗,引用核心函式
//開啟彈窗$('.d_md12 .material .addbox').on('click',function());
//關閉彈窗
// pc點選空白區域關閉視窗
$('.popbox:not(.publish_pop)').click(function(e)
});//pc esc關閉視窗
$(document).keyup(function(event)
});//pc 點選close按鈕關閉彈窗
$('.popbox:not(.publish_pop) .pop_closebtn').click(function(e));
備註:
document.scrollingelement檢測函式:因為瀏覽器獲取和設定 scrolltop 存在相容性,為了簡化上面的示例,我直接使用了 document.scrollingelement 這個新標準,對於不支援的瀏覽器我寫了個 polyfill document.scrollingelement.js
document.scrollingelement.js
/*** polyfill for document.scrollingelement
* */(function ()
var element = null
function scrollingelement () else if (document.body.scrolltop)
var iframe = document.createelement('iframe')
iframe.style.height = '1px'
var doc = iframe.contentwindow.document
doc.write('x
') doc.close()
var iscompliant = doc.documentelement.scrollheight > doc.body.scrollheight
iframe.parentnode.removechild(iframe)
return (element = iscompliant ? document.documentelement : document.body)
} object.defineproperty(document, 'scrollingelement', )
})()
解決彈出層滾動穿透的問題
乙個棘手的問題 彈出層的滾動穿透,即彈出層滾動,那麼被彈出層覆蓋的下面的內容區域也會進行滾動。彈出層我是用的view標籤然後使用的position fixed進行的定位 說一下我的解決思路 一 當彈出層裡面無滾動的時候 可以在遮罩的view標籤上定義乙個防止事件冒泡的方法 catchtouchmov...
解決小程式彈出層滾動穿透的問題
最近在做彈窗的時候遇到的問題,就是遮罩後面的內容可以滾動,查詢資源發現是兩種情況,一是遮罩層有滾動元件,乙個是遮罩層沒有滾動元件,下面就來說說如何解決這兩種情況。使用前後對比 一 當彈出層裡面無滾動的時候 可以在遮罩的view標籤上定義乙個防止事件冒泡的方法 catchtouchmove preve...
分析問題是解決問題的前提
用簡便演算法求下列式子的結果 1 1 6 1 12 1 20 1 30 1 42 1 2 3 1 3 4 1 4 5 1 5 6 1 6 7 1 2 1 3 1 3 1 4 1 4 1 5 1 5 1 6 1 6 1 7 中間很多項都抵消 so 原式 1 2 1 7 5 14 這個問題的解決方案,建...