Pra*_*lur 4 javascript jquery jquery-mobile
我正在使用jquery手机弹出窗口.这是在页面内.有一个图像可以打开此弹出窗口.现在如何仅在弹出窗口打开时阻止整个页面滚动,如果弹出窗口关闭则允许滚动?
<a href="#settingsPopUp" data-rel="popup" data-position-to="window" data-inline="true" data-icon="gear"><img src="settings1.jpg" alt="Settings"></a>
<br>
<div data-role="popup" id="settingsPopUp" data-theme="a" class="ui-corner-all">
<div style="padding:10px 20px;">
<h3>Location Details</h3>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我混合了Lefois的解决方案和Simona Adriani的解决方案.它适用于浏览器和手机WebView(PhoneGap + jquerymobile).
$(document).on('popupafteropen', '[data-role="popup"]', function(event, ui) {
$('body').css('overflow', 'hidden').on('touchmove', function(e) {
e.preventDefault();
});
}).on('popupafterclose', '[data-role="popup"]', function(event, ui) {
$('body').css('overflow', 'auto').off('touchmove');
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17220 次 |
| 最近记录: |