function drop_confirm(msg, url){ if(confirm(msg)){ window.location = url; } } function go(url){ window.location = url; } /* 格式化金额 */ function price_format(price){ if(typeof(PRICE_FORMAT) == 'undefined'){ PRICE_FORMAT = '¥%s'; } price = number_format(price, 2); return PRICE_FORMAT.replace('%s', price); } function number_format(num, ext){ if(ext < 0){ return num; } num = Number(num); if(isNaN(num)){ num = 0; } var _str = num.toString(); var _arr = _str.split('.'); var _int = _arr[0]; var _flt = _arr[1]; if(_str.indexOf('.') == -1){ /* 找不到小数点,则添加 */ if(ext == 0){ return _str; } var _tmp = ''; for(var i = 0; i < ext; i++){ _tmp += '0'; } _str = _str + '.' + _tmp; }else{ if(_flt.length == ext){ return _str; } /* 找得到小数点,则截取 */ if(_flt.length > ext){ _str = _str.substr(0, _str.length - (_flt.length - ext)); if(ext == 0){ _str = _int; } }else{ for(var i = 0; i < ext - _flt.length; i++){ _str += '0'; } } } return _str; } /* 火狐下取本地全路径 */ function getFullPath(obj) { if(obj) { //ie if (window.navigator.userAgent.indexOf("MSIE")>=1) { obj.select(); if(window.navigator.userAgent.indexOf("MSIE") == 25){ obj.blur(); } return document.selection.createRange().text; } //firefox else if(window.navigator.userAgent.indexOf("Firefox")>=1) { if(obj.files) { //return obj.files.item(0).getAsDataURL(); return window.URL.createObjectURL(obj.files.item(0)); } return obj.value; } return obj.value; } } /* 转化JS跳转中的 & */ function transform_char(str) { if(str.indexOf('&')) { str = str.replace(/&/g, "%26"); } return str; } //图片垂直水平缩放裁切显示 (function($){ $.fn.VMiddleImg = function(options) { var defaults={ "width":null, "height":null }; var opts = $.extend({},defaults,options); return $(this).each(function() { var $this = $(this); var objHeight = $this.height(); //图片高度 var objWidth = $this.width(); //图片宽度 var parentHeight = opts.height||$this.parent().height(); //图片父容器高度 var parentWidth = opts.width||$this.parent().width(); //图片父容器宽度 var ratio = objHeight / objWidth; if (objHeight > parentHeight && objWidth > parentWidth) { if (objHeight > objWidth) { //赋值宽高 $this.width(parentWidth); $this.height(parentWidth * ratio); } else { $this.height(parentHeight); $this.width(parentHeight / ratio); } objHeight = $this.height(); //重新获取宽高 objWidth = $this.width(); if (objHeight > objWidth) { $this.css("top", (parentHeight - objHeight) / 2); //定义top属性 } else { //定义left属性 $this.css("left", (parentWidth - objWidth) / 2); } } else { if (objWidth > parentWidth) { $this.css("left", (parentWidth - objWidth) / 2); } $this.css("top", (parentHeight - objHeight) / 2); } }); }; })(jQuery); function DrawImage(ImgD,FitWidth,FitHeight){ var image=new Image(); image.src=ImgD.src; if(image.width>0 && image.height>0) { if(image.width/image.height>= FitWidth/FitHeight) { if(image.width>FitWidth) { ImgD.width=FitWidth; ImgD.height=(image.height*FitWidth)/image.width; } else { ImgD.width=image.width; ImgD.height=image.height; } } else { if(image.height>FitHeight) { ImgD.height=FitHeight; ImgD.width=(image.width*FitHeight)/image.height; } else { ImgD.width=image.width; ImgD.height=image.height; } } } } /** * 浮动DIV定时显示提示信息,如操作成功, 失败等 * @param string tips (提示的内容) * @param int height 显示的信息距离浏览器顶部的高度 * @param int time 显示的时间(按秒算), time > 0 * @sample 点击 * @sample 上面代码表示点击后显示操作成功3秒钟, 距离顶部100px * @copyright ZhouHr 2010-08-27 */ function showTips( tips, height, time ){ var windowWidth = document.documentElement.clientWidth; var tipsDiv = '