我使用以下方法在加载页面时显示加载图像以通知用户加载操作正在进行中。如果我在网页浏览器中按下“后退”按钮,有时页面会从加载图像开始,页面被删除。我想确保如果用户在网络浏览器中按下后退/前进按钮,则需要显示加载图像。Jquery加载图像 - 在Web浏览器中处理Back/Forward按钮
正在使用的方法。
的Javascript:
<script language="javascript" type="text/javascript">
$(document).ready(function(){
//This line below would hide the div when the page load by default
$('#loading').hide();
//This would display when the user clicks the button
$('#buttonID').click(function(){
if($('#search_string').val().length !== 0) {
$('#loading').show();
}
});
$('a.la').click(function(){
$('#loading').show();
});
});
$(window).load(function() {
$('#loading').hide();
});
</script>
的CSS
#loading {
width: 100%;
height: 100%;
top: 0;
left: 0;
position: fixed;
display: block;
z-index: 99;
text-align: center;
}
#loading-image {
position: absolute;
top: 160px;
left: 130px;
z-index: 100;
}
HTML
<button id='buttonID' type="submit"></button>
<a class="la" href="search.php">Some text</a><br>
您可以尝试添加''到'