//压缩图片方法 function compressImg(file,callback){ var src; var fileSize = parseFloat(parseInt(file['size'])/1024/1024).toFixed(2); var read = new FileReader(); read.readAsDataURL(file); read.onload = function (e) { var img = new Image(); img.src = e.targ
在js中实现邮箱格式的验证 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>在此处插入标题</title><script
有时候做项目会用到js的date日期格式,因为Date()返回的格式不是我们需要的, Date()返回格式: Thu Mar 19 2015 12:00:00 GMT+0800 (中国标准时间) 而我们则需要这样的格式: 2015-3-19 12:00:00 除非是在后台处理好时间格式,然后在页面直接显示. 那如何用js格式化date日期值呢? 1.js方法返回值:2015-03-19 var formatDate = function (date) { var y = date.getFull
js处理数据库时间格式 数据库返回时间格式:/Date(1332919782070)/ 方法: function ChangeDateFormat(val) { if (val != null) { var date = new Date(parseInt(val.replace("/Date(", "").replace(")/", ""), 10)); //月份为0-11,所以+1,月份小于10时补个0 var month
fileReader HTML5定义了FileReader作为文件API的重要成员用于读取文件,根据W3C的定义,FileReader接口提供了读取文件的方法和包含读取结果的事件模型. FileReader的使用方式非常简单,可以按照如下步骤创建FileReader对象并调用其方法: 1.检测浏览器对FileReader的支持 if(window.FileReader) { var fr = new FileReader(); // add your code here } else { ale