Skip to content

Instantly share code, notes, and snippets.

@moodpo
moodpo / HTML 5 上传图片
Last active September 7, 2015 11:10 — forked from FrankFan/HTML 5 上传图片
使用H5特性上传图片
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<meta name="author" content="EdieLei" />
<title>HTML5 图片上传预览</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('#img').change(function(){
@moodpo
moodpo / gist:6c45bbb989a9dd02b82b
Last active August 29, 2015 14:20
用户代理字符串检测
var client = function(){
// 呈现引擎
var engine = {
ie: 0,
gecko: 0,
webkit: 0,
khtml: 0,
opera: 0,
@moodpo
moodpo / gist:10628720
Created April 14, 2014 08:44
Javascript/js兼容各个浏览器的本地图片上传即时预览效果(仅预览)
function change() {
var pic = document.getElementById("preview");
var file = document.getElementById("f");
var ext=file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();
// gif在IE浏览器暂时无法显示
if(ext!='png'&&ext!='jpg'&&ext!='jpeg'){
alert("文件必须为图片!"); return;
}
// IE浏览器
if (document.all) {