我有这个例子jquery popup code:http://jsfiddle.net/9jrrd1hL/
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<body>
<div data-role="page">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<a href="#myPopupDialog" data-rel="popup" data-position-to="window" data-transition="fade" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">Open Dialog Popup</a>
<p>Table Example:</p>
<style type="text/css">
table.example5 {background-color:GreenYellow;border:1px dotted black;width:100%;}
table.example5 th, table.example5 td {text-align:center;border:0;padding:5px;background-color:transparent;}
table.example5 th {background-color:LimeGreen;color:white;}
table.example5 th:first-child {width:20%;}
</style>
<table class="example5">
<tr>
<th rowspan="2">Table header</th><td>Table cell 1
</tr>
<tr>
<td>Table cell 2</td>
</tr>
</table>
<p>Frames Example:</p>
<iframe src="/html/templates/frames/frames_example_1.html" width="80%" height="90%">
</iframe>
<p>Image Example:</p>
<a href="http://www.quackit.com/travel/new_zealand/milford_sound"><img src="/pix/milford_sound/milford_sound_t.jpg" style="max-width:100%" alt="Milford Sound in New Zealand" /></a>
<p>Frames Example:</p>
<iframe src="/html/templates/frames/frames_example_1.html" width="80%" height="90%">
</iframe>
<p>Image Example:</p>
<a href="http://www.quackit.com/travel/new_zealand/milford_sound"><img src="/pix/milford_sound/milford_sound_t.jpg" style="max-width:100%" alt="Milford Sound in New Zealand" /></a>
<div data-role="popup" id="myPopupDialog">
<div data-role="header">
<h1>Header Text</h1>
</div>
<div data-role="main" class="ui-content">
<h2>Welcome to my Popup Dialog!</h2>
<p>jQuery Mobile is FUN!</p>
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b ui-icon-back ui-btn-icon-left" data-rel="back">Go Back</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
我的真实代码背景很大,所以我想做的是每次打开弹出窗口时我希望它能够避免用户根据背景向下或向上滚动。
答案 0 :(得分:1)
在打开弹出按钮
时使用此功能<a href="#myPopupDialog" data-rel="popup" data-position-to="window" data-transition="fade" class="ui-btn ui-corner-all ui-shadow ui-btn-inline" onclick="document.body.style.overflowY = 'hidden'">>Open Dialog Popup</a>
和你的goback按钮
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b ui-icon-back ui-btn-icon-left" data-rel="back" onclick="document.body.style.overflowY = 'visible'">Go Back</a>
您还可以向容器div添加ID,并将按钮上的onclick
功能更改为onclick="document.getElementById("containerID").style.overflow = 'hidden'";
和onclick="document.getElementById("containerID").style.overflow = 'visible'";
答案 1 :(得分:0)
您可以将body
溢出设置为隐藏,如下所示:
$(body).css("overflow", "hidden");
并且只需使用滚动回滚:
$(body).css("overflow", "auto");
希望它有所帮助。