整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:

jquery css3页面弹出loading加载

jquery css3页面弹出loading加载

在前段页面制作中,一个选项卡往往需要加载的内容会很多,例如一些图片站和特效站点,过长的加载和不完整的加载会给读者很不好的体验,这时候,如果我们在加载的过程中加入一个小小的设定,就是接下来要给大家展现的,loading等待加载提示,大家可以自由发挥把加载美化城进度条也,用户体验会更好一些。

不多罗嗦大家看效果吧

完成源码:(ps:js文件真心贴不出来,小编也很苦恼,需要还是留邮箱吧,小编保证,只是发源码,绝不广告骚扰)

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>jquery css3页面弹出loading加载</title>

</head>

<body>

<style type="text/css">

/* reset */

*{margin:0;padding:0;list-style-type:none;}

a{blr:expression(this.onFocus=this.blur())}/*去掉a标签的虚线框,避免出现奇怪的选中区域*/

:focus{outline:0;}

label{cursor:pointer;}

img{vertical-align:middle;}

table{empty-cells:show;border-collapse:collapse;border-spacing:0;}

h1{font-size:16px;}h2,h3,h4{font-size:14px;}h5,h6{font-size:12px;}

abbr,acronym{border:0;font-variant:normal}

address,caption,cite,code,dfn,em,th,var,optgroup{font-style:normal;font-weight:normal}

input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit}

input,button,textarea,select{*font-size:100%}

a,img{border:0;}

a,a:visited{color:#5e5e5e; text-decoration:none;}

a:hover{color:#4183C4;text-decoration:underline;}

.clear{display:block;overflow:hidden;clear:both;height:0;line-height:0;font-size:0;}

.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}

.clearfix{display:inline-table;}/* Hides from IE-mac \*/

*html .clearfix{height:1%;}

.clearfix{display:block;}/* End hide from IE-mac */

*+html .clearfix{min-height:1%;}

body{font:12px/180% Arial,Lucida,Verdana,"宋体",Helvetica,sans-serif;color:#333;background:#fff;}

/* shortcut */

.shortcut{height:32px;line-height:32px;font-size:12px;background:#eee;text-transform:uppercase;box-shadow:1px 0px 2px rgba(0,0,0,0.2);border-bottom:1px solid #DDDDDD;}

.shortcut h1{font-size:14px;font-family:"微软雅黑","宋体";}

.shortcut a,.shortcut h1{padding:0px 10px;letter-spacing:1px;color:#333;text-shadow:0px 1px 1px #fff;display:block;float:left;width:360px;height:32px;overflow:hidden;}

.shortcut a:hover{background:#fff;}

.shortcut span.right{float:right;display:inline-block;width:468px;height:15px;overflow:hidden;margin:8px 5px 0 0;}

.shortcut .close{

background:url(/Public/images/close-demo.gif) no-repeat 0 0;width:20px;height:20px;line-height:99em;overflow:hidden;display:inline-block;margin:6px 10px 0 10px;float:right;padding:0;

-webkit-transition:all .3s ease-out 0s;

-moz-transition:all .3s ease-out 0s;

-ms-transition:all .3s ease-out 0s;

-o-transition:all .3s ease-out 0s;

transition:all .3s ease-out 0s;

}

.shortcut .close:hover{background:url(/Public/images/close-demo.gif) no-repeat 0 -20px}

.shortcut .close:active{background:url(/Public/images/close-demo.gif) no-repeat 0 -40px}

</style>

<script type="text/javascript" src="./jquery css3页面弹出loading加载代码_files/jquery-1.4.2.min.js"></script>

<script type="text/javascript">

$(document).ready(function(){

var iframeHeight=function () {

var _height=$(window).height() - 34;

$('#content').height(_height);

}

window.onresize=iframeHeight;

$(function () {

iframeHeight();

});

});

</script>

<div id="container" style="overflow:hidden;">

<iframe border="0" id="content" src="./jquery css3页面弹出loading加载代码_files/index.html" frameborder="0" height="100%" width="100%" style="height: 577px;"></iframe>

</div>

<script type="text/javascript">

var _bdhmProtocol=(("https:"==document.location.protocol) ? " https://" : " http://");

document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F382f81c966395258f239157654081890' type='text/javascript'%3E%3C/script%3E"));

</script>

<script src="./jquery css3页面弹出loading加载代码_files/h.js" type="text/javascript"></script>

</body>

</html>

天给大家介绍一个非常好用的前端插件jQuery UI。

jQuery UI是以 jQuery 为基础的开源 JavaScript 网页用户界面代码库。包含底层用户交互、动画、特效和可更换主题的可视控件。

下面是一个以jQuery UI实现的弹出登录框功能,代码非常简单。

<!DOCTYPE html>

<html>

<head>

<title> new document </title>

<meta charset="utf-8">

<link rel="stylesheet" href="css/bootstrap.css">

<link rel="stylesheet" href="css/jquery-ui.css">

</head>

<body>

<h1>jQueryUI:Widgets —— Dialog</h1>

<h3>弹出式对话框</h3>

<a id="btn-login" class="btn btn-success" href="#">我要登录</a>

<div id="dialog-login" title="用户登录">

<form action="">

用户名:<input type="text"><br>

密码名:<input type="password"><br>

</form>

</div>

<script src="js/jquery-1.11.3.js"></script>

<script src="JS/jquery-ui.js"></script>

<script>

var $dialog=$("#dialog-login")

$dialog.dialog({

autoOpen:false,

modal:false,

show:{effect:"blind",duration:1000},

hide:{effect:"explode",duration:1000},

buttons:{

"登录":()=>setTimeout(()=>{

alert("登录成功");

$dialog.dialog("close");

},1000),

"取消":()=>$dialog.dialog("close")

},

close(){

$("form").get(0).reset()

}

});

$("#btn-login").click(()=>{

$dialog.dialog("open")

})

</script>

</body>

</html>

<div class="subcategories">这里有点击事件</div>
<div class="subcategories">这里有点击事件</div>
<div class="subcategories">这里有点击事件</div>
<script type="text/javascript">
//阻止点击事件
$(function() {
    $(".subcategories").click(function(event) {
        event.stopPropagation();
    });
});
</script>

么是JS事件冒泡?

在一个对象上触发某类事件(比如单击onclick事件), 如果此对象定义了此事件的处理程序, 那么此事件就会调用这个处理程序, 如果没有定义此事件处理程序或者事件返回true,

那么这个事件会向这个对象的父级对象传播, 从里到外, 直至它被处理(父级对象所有同类事件都将被激活), 或者它到达了对象层次的最顶层, 即document对象(有些浏览器是window)。

如何来阻止Jquery事件冒泡?

通过一个小例子来解释

<!DOCTYPE html>
<html>
<head runat="server">
<title>Porschev---Jquery 事件冒泡</title>
<script src="jquery-1.3.2-vsdoc.js" type="text/javascript"></script>
</head>
<body>
  <form id="form1" runat="server">
    <div id="divOne" onclick="alert('我是最外层');">
      <div id="divTwo" onclick="alert('我是中间层!')">
        <a id="hr_three" href="http://www.baidu.com" mce_href="http://www.baidu.com"onclick="alert('我是最里层!')">点击我</a>
      </div>
    </div>
  </form>
</body>
</html>

比如上面这个页面,

分为三层:divOne是第外层,divTwo中间层,hr_three是最里层;

他们都有各自的click事件,最里层a标签还有href属性。

运行页面,点击“点击我”,会依次弹出:我是最里层---->我是中间层---->我是最外层

---->然后再链接到百度.


这就是事件冒泡, 本来我只点击ID为hr_three的标签, 但是确执行了三个alert操作。

事件冒泡过程(以标签ID表示):hr_three----> divTwo----> divOne 。从最里层冒泡到最外层。

如何来阻止?

1.event.stopPropagation();

<script type="text/javascript">
$(function() {
$("#hr_three").click(function(event) {
event.stopPropagation();
});
});
<script>

再点击"点击我", 会弹出:我是最里层, 然后链接到百度


2.return false;

如果头部加入的是以下代码

<script type="text/javascript">
$(function() {
  $("#hr_three").click(function(event) {
    return false;
  });
});
<script>

再点击"点击我", 会弹出:我是最里层, 但不会执行链接到百度页面


由此可以看出:

1.event.stopPropagation();

事件处理过程中,阻止了事件冒泡,但不会阻击默认行为(它就执行了超链接的跳转)


2.return false;

事件处理过程中,阻止了事件冒泡,也阻止了默认行为(比如刚才它就没有执行超链接的跳转)


还有一种有冒泡有关的:

3.event.preventDefault();

如果把它放在头部A标签的click事件中, 点击"点击我"。

会发现它依次弹出:我是最里层---->我是中间层---->我是最外层, 但最后却没有跳转到百度

它的作用是:事件处理过程中, 不阻击事件冒泡, 但阻击默认行为(它只执行所有弹框, 却没有执行超链接跳转)