日期:2014-05-18 浏览次数:20114 次
以下是HTML网页特效代码,点击运行按钮可查看效果: 以下是程序代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <body> <br /><br /><br /><br /> <script> var isIE = (document.all) ? true : false; var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6); function Each(list, fun){ for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); } }; var $ = function (id) { return "string" == typeof id ? document.getElementById(id) : id; }; var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } Object.extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } return destination; } Function.prototype.bind = function(object) { var __method = this, args = Array.apply(null, arguments); args.shift(); return function() { return __method.apply(object, args); } } var OverLay = Class.create(); OverLay.prototype = { initialize: function(overlay, options) { this.Lay = $(overlay);//覆盖层 //ie6设置覆盖层大小程序 this._size = function(){}; this.SetOptions(options); this.Color = this.options.Color; this.Opacity = parseInt(this.options.Opacity); this.zIndex = parseInt(this.options.zIndex); this.Set(); }, //设置默认属性 SetOptions: function(options) { this.options = {//默认值 Color:"#fff",//背景色 Opacity:50,//透明度(0-100) zIndex:1000//层叠顺序 }; Object.extend(this.options, options || {}); }, //创建 Set: function() { this.Lay.style.display = "none"; this.Lay.style.zIndex = this.zIndex; this.Lay.style.left = this.Lay.style.top = 0; if(isIE6){ this.Lay.style.position = "absolute"; this._size = function(){ this.Lay.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px"; this.Lay.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px"; }.bind(this); //遮盖select this.Lay.innerHTML = '<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;filter:alpha(opacity=0);"></iframe>' } else { this.Lay.style.position = "fixed"; this.Lay.style.width = this.Lay.style.height = "100%"; } }, //显示 Show: function() { //设置样式 this.Lay.style.backgroundColor = this.Color; //设置透明度 if(isIE){ this.Lay.style.filter = "alpha(opacity:" + this.Opacity + ")"; } else { this.Lay.style.opacity = this.Opacity / 100; } //兼容ie6 if(isIE6){ this._size(); window.attachEvent("onresize", this._size); } this.Lay.style.display = "block"; }, //关闭 Close: function() { this.Lay.style.display = "none"; if(isIE6){ window.detachEvent("onresize", this._size); } } }; var LightBox = Class.create(); LightBox.prototype = { initialize: function(box, overlay, options) { this.Box = $(box);//显示层 this.OverLay = new OverLay(overlay, options);//覆盖层 this.SetOptions(options); this.Fixed = !!this.options.Fixed; this.Over = !!this.options.Over; this.Center = !!this.options.Center; this.onShow = this.options.onShow; this.Box.style.zIndex = this.OverLay.zIndex + 1; this.Box.style.display = "none"; //兼容ie6用的属性 if(isIE6){ this._top = this._left = 0; this._select = []; } }, //设置默认属性 SetOptions: function(options