网页装载JS特效 任何网页适用

这是从别人网站学习来的代码,现在分享出来,大家一起学习!

本效果适用于任何网站页面,下面提供出针对Z-BLOG单页日至的修改方法.其他页面,如首页,修改方法一样.

修改/TEMPLATE/single.html

1.找到<head>标签 在下面添加如下代码:

<style type="text/css">
 #loader_container {
 text-align:center;
 position:absolute;
 top:40%;
 width:100%;
 left: 0;
 }
 #loader {
 font-family:Tahoma, Helvetica, sans;
 font-size:11.5px;
 color:#000000;
 background-color:#FFFFFF;
 padding:10px 0 16px 0;
 margin:0 auto;
 display:block;
 width:230px;
 border:1px solid #5a667b;
 text-align:left;
 z-index:2;
 }
 #loader_bg {background-color:#e4e7eb;
 position:relative;
 top:8px;
 left:8px;
 height:7px;
 width:213px;
 font-size:1px}
 #progress {
 height:5px;
 font-size:1px;
 width:1px;
 position:relative;
 top:1px;
 left:0px;
 background-color:#77A9E0
 }
 </style>
<script language="JavaScript">
 //读取框
 var t_id = setInterval(animate,20);
 var pos=0;
 var dir=2;
 var len=0;
function animate(){
 var elem = document.getElementById('progress');
 if(elem != null) {
 if (pos==0) len += dir;
 if&nbsp
 ;(len>32 || pos>179) pos += dir;
 if (pos>179) len -= dir;
 if (pos>179 && len==0) pos=0;
 elem.style.left = pos;
 elem.style.width = len;
 }
 }
function remove_loading() {
 this.clearInterval(t_id);
 var targelem = document.getElementById('loader_container');
 targelem.style.display='none';
 targelem.style.visibility='hidden';
 initJS();
 }
 </script>

2.找到<body ….>标签 在下面添加

<div id="loader_container">
 <div id="loader">
 <div align="center">
 本站页面正在用吃奶de劲加载中... <br>
 版权归 www.Wilf.cn 所有 ˉεˉ 别急嘛
 </div>
 <div id="loader_bg"><div id="progress"> </div></div>
 </div>
 </div>

3.修改body标签为

<body onload="remove_loading()" onkeydown="PressKey()">

为了方便使用,以上代码已经写成了zblog插件,http://bbs.zblogcn.com/thread-23157-1-2.html

5 thoughts to “网页装载JS特效 任何网页适用”

回复 ting 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注