js的几个库
http://www.w3.org/TR/html-media-capture/
demo:http://jsfiddle.net/pmatseykanets/R99NY/
<!DOCTYPE html>
<html>
<head>
<title>jQM input file capture</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
</head>
<body> <div data-role="page" id="page">
<style>
#preview {
width: 80%; max-width: 300px;
}
#preview img {
width: 100%;
}
.hiddenfile {
width: 0px;
height: 0px;
overflow: hidden;
}
</style>
<div data-role="header">
<h3>Header</h3>
</div>
<div data-role="content">
<button id="chooseFile">Choose file</button>
<div class="hiddenfile">
<input type="file" data-clear-btn="false" name="image" accept="image/*" capture>
</div>
<div id="preview">
</div>
<ul id="info" data-role="listview" data-inset="true">
</ul>
</div> </div> <script>
$('#page').on('pageinit', function(){
$("#chooseFile").click(function(e){
e.preventDefault();
$("input[type=file]").trigger("click");
});
$("input[type=file]").change(function(){
var file = $("input[type=file]")[0].files[0];
$("#preview").empty();
displayAsImage3(file, "preview"); $info = $("#info");
$info.empty();
if (file && file.name) {
$info.append("<li>name:<span>" + file.name + "</span></li>");
}
if (file && file.type) {
$info.append("<li>size:<span>" + file.type + " bytes</span></li>");
}
if (file && file.size) {
$info.append("<li>size:<span>" + file.size + " bytes</span></li>");
}
if (file && file.lastModifiedDate) {
$info.append("<li>lastModifiedDate:<span>" + file.lastModifiedDate + " bytes</span></li>");
}
$info.listview("refresh");
});
}); function displayAsImage3(file, containerid) {
if (typeof FileReader !== "undefined") {
var container = document.getElementById(containerid),
img = document.createElement("img"),
reader;
container.appendChild(img);
reader = new FileReader();
reader.onload = (function (theImg) {
return function (evt) {
theImg.src = evt.target.result;
};
}(img));
reader.readAsDataURL(file);
}
} </script>
</body>
</html>
js的几个库的更多相关文章
- Node.js 数据库实时监控库 node-dbmon
node-dbmon 是一个 Node.js 数据库实时监控库,如果你希望在数据库表数据更改后,或者是文件修改后能更新 GUI,那么这个库正好适合你. https://github.com/strap ...
- 【Node.js 自己封装的库 http_parse, libuv】
[Node.js 自己封装的库 http_parse, libuv] Node.js 介绍:一个网络框架,更多:http://www.oschina.net/p/nodejs 官网:http://no ...
- js基础和工具库
/* * 作者: 胡乐 * 2015/4/18 * js 基础 和 工具库 * * * */ //根据获取对象 function hGetId(id){ return document.getElem ...
- js文件上传库
收集了2个与具体UI库和框架无任何耦合的JS文件上传库:支持断点续传.支持npm安装. resumable.js fileapi
- 深入解析Backbone.js框架的依赖库Underscore.js的作用
这篇文章主要介绍了深入解析Backbone.js框架的依赖库Underscore.js的作用,用过Node.js的朋友对Underscore一定不会陌生:)需要的朋友可以参考下 backbone必须依 ...
- HTML5全屏背景视频与 CSS 和 JS(插件或库)
译文原链接:http://codetheory.in/html5-fullscreen-background-video/ 前言: 当网页载入时,自动播放的全屏背景视频已经成为当前颇受欢迎的趋势. 就 ...
- Blazor组件自做一 : 使用JS隔离封装viewerjs库
Viewer.js库是一个实用的js库,用于图片浏览,放大缩小翻转幻灯片播放等实用操作 本文相关参考链接 JavaScript 模块中的 JavaScript 隔离 Viewer.js工程 Blazo ...
- smartcrop.js智能图片裁剪库
今天将为大家介绍一款近期github上很不错的开源库 – smartcrop.js.它是一款图片处理的智能裁剪库.在很多项目开发中,经常会遇见上传图片的场景,它可能是用户照片信息,也可能是商品图片等. ...
- 自己写一个JS单向数据流动库----one way binding
JS单向流动其实就是数据到视图的过程, 这几天突发奇想,想着弄一个插件, 把DOM结构使用JS进行描述: 因为DOM中的Class , content, id, attribute, 事件, 子元素全 ...
- RSuite 一个基于 React.js 的 Web 组件库
RSuite http://rsuite.github.io RSuite 是一个基于 React.js 开发的 Web 组件库,参考 Bootstrap 设计,提供其中常用组件,支持响应式布局. 我 ...
随机推荐
- 题解-------CF372C Watching Fireworks is Fun
传送门 一道有趣的DP 题目大意 城镇中有$n$个位置,有$m$个烟花要放.第$i$个烟花放出的时间记为$t_{i}$,放出的位置记为$a_{i}$.如果烟花放出的时候,你处在位置$x$,那么你将收获 ...
- 3. 监控利器nagios手把手企业级实战第二部
1. 编辑hosts.cfg增加被监控的主机[root@nagios etc]# cat objects/hosts.cfg define host{ use ...
- 14 微服务电商【黑马乐优商城】:day02-springcloud(搭建Eureka注册中心)
本项目的笔记和资料的Download,请点击这一句话自行获取. day01-springboot(理论篇) :day01-springboot(实践篇) day02-springcloud(理论篇一) ...
- TPO1-3Timberline Vegetabtion on Mountain|have the advantage over
The upper timberline, like the snow line, is highest in the tropics and lowest in the Polar Regions. ...
- sin之舞---蓝桥杯练习
问题描述 最近FJ为他的奶牛们开设了数学分析课,FJ知道若要学好这门课,必须有一个好的三角函数基本功.所以他准备和奶牛们做一个“Sine之舞”的游戏,寓教于乐,提高奶牛们的计算能力. 不妨设 An=s ...
- day47-线程-锁和死锁
#1.锁:防止多个线程同时读写某一块内存区域. from threading import Thread from threading import Lock def func(): global n ...
- HttpClient的userAgent和refer问题
HttpClient本质是模拟浏览器去请求网址,获取请求response. 为了更真实的模拟浏览器,不被限制,需要设置一些请求header. 如果是爬虫的话,老虑的会更多些,爬取网站在HttpClie ...
- @Transactional回滚问题(try catch、嵌套)
Spring 事务注解 @Transactional 本来可以保证原子性,如果事务内有报错的话,整个事务可以保证回滚,但是加上try catch或者事务嵌套,可能会导致事务回滚失败.测试一波. 准备 ...
- git相关学习地址
https://git-scm.com/book/zh/v2 这篇文章写得不错,值得一读
- Horizon公司环境