// javascript document // 浏览器信息 var browserinfo = (function() { var version = ["", ""], browser = "unkonw", agentinfo = navigator.useragent.tolowercase(); if (agentinfo.indexof("trident/7.0") > -1) { version = agentinfo.match(/rv:([\d]+)/); browser = "ie" } if (agentinfo.match(/msie ([\d.]+)/)) { version = agentinfo.match(/msie ([\d]+)/); browser = "ie" } if (agentinfo.match(/firefox\/([\d.]+)/)) { version = agentinfo.match(/firefox\/([\d]+)/); browser = "firefox" } if (agentinfo.match(/chrome\/([\d.]+)/)) { version = agentinfo.match(/chrome\/([\d]+)/); browser = "chrome" } if (agentinfo.match(/opera.([\d.]+)/)) { version = agentinfo.match(/opera.([\d]+)/); browser = "opera" } if (agentinfo.match(/version\/([\d.]+).*safari/)) { version = agentinfo.match(/version\/([\d]+).*safari/); browser = "safari" } return { 'name': browser, 'version': version[1], 'ua': navigator.useragent, 'plug': navigator.plugins } })(); //弹出窗口 var i4popup = function(options){ var $this = this; this.options = $.extend({ 'mask': { 'display': true }, 'content': { 'html': '', 'width': 600, 'height': 300, 'class': 'popup' }, 'close': { 'display': true, 'text': ' ' }, 'transitiontime': 300 }, options, true); this.dom = $('
').attr({ 'id': 'popup' + parseint(math.random() * 100000), 'class': this.options.content['class'] }); this.show = function(){ if($this.options.mask.display) { i4popup.prototype.mask.show().css({ 'height':$(document).height() }); if(!(browserinfo.name== 'ie' && browserinfo.version == '6')) i4popup.prototype.mask.animate({ 'opacity': 1 }, $this.options.transitiontime); } $this.dom.show(); if(!(browserinfo.name== 'ie' && browserinfo.version == '6')) $this.dom.animate({ 'opacity': 1 }, $this.options.transitiontime); }; this.hide = function(){ if($this.options.mask.display) { if(!(browserinfo.name== 'ie' && browserinfo.version == '6')) { i4popup.prototype.mask.animate({ 'opacity': 0 }, $this.options.transitiontime); settimeout(function(){ i4popup.prototype.mask.hide(); }, $this.options.transitiontime) } else i4popup.prototype.mask.hide(); } if(!(browserinfo.name== 'ie' && browserinfo.version == '6')) { $this.dom.animate({ 'opacity': 0 }, $this.options.transitiontime); settimeout(function(){ $this.dom.hide(); }, $this.options.transitiontime) } else $this.dom.hide(); }; this.create = function(){ if(!(browserinfo.name== 'ie' && browserinfo.version == '6')) $this.dom.css({ 'opacity': 0, 'position': 'fixed' }) else $this.dom.css({ 'position': 'absolute' }) $this.dom.css({ 'width': $this.options.content.width, 'height': $this.options.content.height, 'display': 'none', 'z-index': 9999, 'overflow': 'hidden' }); if(typeof $this.options.content.html.show != 'undefined') $this.options.content.html.show(); $this.dom.html($this.options.content.html).css({ 'left': ($(window).width() - $this.options.content.width) / 2, 'top': ($(window).height() - $this.options.content.height) / 2 }) if($this.options.close.display) $this.dom.append($('').html($this.options.close.text).on('click', function(){ $this.hide(); })); }; this.init = function(){ $this.create(); $('body').append($this.dom); $(window).resize(function(){ $this.create(); }); if(browserinfo.name=='ie' && browserinfo.version=='6') { $(window).scroll(function(e){ var st = $('body,html').scrolltop(); $this.dom.css({ 'top': ($(window).height() - $this.options.content.height) / 2 + st }); }); } }; return this; }; i4popup.prototype.mask = $('
 
').attr('id', 'mask' + parseint(math.random() * 100000)).css({ 'width': '100%', 'height': $(document).height(), 'background': !(browserinfo.name== 'ie' && (browserinfo.version == '6' || browserinfo.version == '7' || browserinfo.version == '8')) ? 'rgba(0, 0, 0, 0.6)' : 'url(img/search_bg.png) repeat', 'display': 'none', 'z-index': 9998, 'position': 'absolute', 'left': 0, 'top': 0 }).appendto('body'); if(!(browserinfo.name== 'ie' && browserinfo.version == '6')) i4popup.prototype.mask.css({ 'opacity': 0 }) //输入提示 var i4inputhint = function(options){ var $this = this; this.options = $.extend({ 'hint': '请输入内容', 'hintcolor': '#aaa', 'contentcolor': '#333' }, options, true); this.val = function(str){ if(typeof str != 'undefined') return $this.options.dom.val(str); if($this.options.dom.val() == $this.options.hint) return ''; return $this.options.dom.val(); }; this.into = function(){ $this.options.dom.val('').css({ 'color': $this.options.contentcolor }); }; this.out = function(){ $this.options.dom.val($this.options.hint).css({ 'color': $this.options.hintcolor }); }; if(typeof $this.options.dom == 'undefined') return $this; if($this.options.dom.val() == '' || $this.options.dom.val() == $this.options.hint) $this.out(); $this.options.dom.focus(function(){ if($this.options.dom.val() == $this.options.hint || $this.options.dom.val() == '') $this.into(); }).blur(function(){ if($this.options.dom.val() == '') $this.out(); }); }