为WP主题添加”网页加载中”的特效
发表时间:2010-10-7 评论:1 点击 4,742+
打开header.php模板文件
第一步:加载jquery.min.js
外链接格式:
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.3.min.js"></script>
内链格式:
<script type="text/javascript" src="<?php bloginfo(‘stylesheet_directory’); ?>/js/jquery.min.js" ></script>
第二步:在</head>前添加一段JS代码
<script type="text/javascript">
jQuery(function(){
jQuery(‘#loading-one’).empty().append(‘页面加载完毕.’).parent().fadeOut(‘slow’);
});</script>
第三步:在<body>后添加显示效果样式
<div id="loading" style="position:fixed !important;position:absolute;top:0;left:0;height:100%; width:100%; z-index:999; background:#000 url(这里输入一个图片地址,也可以不用填) no-repeat center; opacity:0.6; filter:alpha(opacity=60);font-size:14px;line-height:20px;" onclick="javascript:turnoff(‘loading’)">
<p id="loading-one" style="color:#fff;position:absolute; top:50%; left:50%; margin:50px 0 0 -50px; padding:3px 10px;" onclick="javascript:turnoff(‘loading’)">页面载入中,请稍后…</p>
</div>
好了就这么简单!
嗯,不错,谢谢分享,我已经加到我的博客上了