上传图片+浏览+裁切 Demo(无后台处理部分)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="css/imgareaselect-default.css">
<buttom class="btn upload">upload</buttom>
</head>
<body>
<input type="file" name="" id="file-upload">
<div class="img"> </div>
</body>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.imgareaselect.js"></script>
<script>
window.URL = window.URL || window.webkitURL;
$("body").on("change", "#file-upload", function() {
var file = $("#file-upload").get(0).files[0];
var img = new Image();
img.src = window.URL.createObjectURL(file);
img.onload = function(e) {
window.URL.revokeObjectURL(this.src);
load_select();
}
$(".img").append(img);
});
$("body").on("click", ".upload", function() {
var jq = $(".img > img");
var img = jq.attr("src");
var xPos = jq.attr("data-xpos");
var yPos = jq.attr("data-ypos");
var width = jq.attr("data-width");
var height = jq.attr("data-height");
console.log("the range of pic is");
console.log("x: %s, y: %s, w: %s, h: %s", xPos, yPos, width, height);
});
function load_select() {
var jq = $(".img > img");
jq.imgAreaSelect({
selectionColor: "blue",
aspectRatio: "4:3",
selectionOpacity: 0.2,
onSelectEnd: function(img, selection) {
jq.attr("data-xpos", selection.x1);
jq.attr("data-ypos", selection.y1);
jq.attr("data-width", selection.width);
jq.attr("data-height", selection.height);
}
});
}
</script>
</html>
插件:http://odyniec.net/projects/imgareaselect/
上传图片+浏览+裁切 Demo(无后台处理部分)的更多相关文章
- 无后台的网站 内容暂存json
当网站无后台时,将数据暂存储为json文档,然后通过调用json文件获取数据填充前端页面 存储json格式的文件 [ { "id": 1, "cat": &qu ...
- 富文本编辑器上传图片需要配置js,后台代码
富文本编辑器上传图片需要配置js,后台代码
- arcgisserver成功发布服务后,浏览服务,无地图显示
软件:ArcMap10.2,ArcgisCatalog10.2 方法:ArcMap10.2添加数据库连接,成功登陆数据库后,拖拽目标图层至Map窗口,对各个图层进行符号化设置 ArcCatalog中找 ...
- 一周一个小demo — 前端后台的交互实例
这一周呢,本K在大神的指导下,完成了一个利用ajax与php文件上传处理相结合的一个留言板功能的小实例,下面就让本K来带大家瞅瞅如何实现这一种功能. 一.界面概览 首先我们来看一下这个小demo的具体 ...
- ArcGIS Server浏览地图服务无响应原因分析说明
1.问题描述 从4月17号下午5时起,至18号晚9点,客户单位部分通过ArcGIS Server发布的地图服务(该部分地图服务的数据源为数据库SJZX)无法加载浏览,表现为长时间无响应.同时,通过Ar ...
- 2、微信小程序之弹幕的实现(无后台)
对弹幕功能主要利用环信来实现的,读者也许对环信这个东西很陌生,请先自行了解这环信再来看这文章. 环信开发文档:http://docs.easemob.com/im/400webimintegratio ...
- 1、微信小程序----弹幕的实现(无后台)
小程序刚刚出来,现在网上的demo是多,但是要找到一个自己需要的却不容易.今天跟大家分享自己写的一个弹幕功能. 先来一张效果图: 我的思路是这样的,先用<switch>标签确定是否打开弹幕 ...
- 无后台应用 Stash Backend
Stash Backend 是Github上的开源项目 https://github.com/gaboratorium/stash,目的在于提供一套方便使用.方便部署的后台应用.特别适合为Web前端和 ...
- 微信小程序-游记分享(无后台)
游记分享 博客班级 https://edu.cnblogs.com/campus/zjcsxy/SE2020 作业要求 https://edu.cnblogs.com/campus/zjcsxy/SE ...
随机推荐
- Reviewing the Blog Module
Reviewing the Blog Module Throughout the tutorial, we have created a fully functional CRUD module us ...
- CSS3 动态魔方的展示
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- margin,padding之我见
在网页布局中,margin和padding绝对会占很重要的作用,但是在实际的项目中,很多新手前端程序员们往往不能正确的使用它们,导致会出现一些不必要的麻烦,下面是我在前几天的项目中遇到的一些问题,以及 ...
- HTML5 服务器发送事件
单向传输:服务器端——>客户端 作用:传回的能每过3s重新刷新一遍.从而能过跟数据库同步,与ajax配合使用 一.客户端写法 必须的用 message 方法 JSON.parse() ...
- gluster 安装配置基本指南
基于网络上的多篇文章,做了一些调整. gluster安装 ### Installing Gluster wget -P /etc/yum.repos.d http://download.gluste ...
- C#.net在后台执行javascript
string script = string.Format("<script type='text/javascript' >alert('{0}');</script&g ...
- 20160531-20160607springmvc入门
springmvc的基础知识 什么是springmvc? springmvc框架原理(掌握) 前端控制器.处理器映射器.处理器适配器.视图解析器 springmvc入门程序 目的:对前端控制器.处理器 ...
- solr-tomcat 中文乱码
<Connector URIEncoding="UTF-8" port="8080" protocol="HTTP/1.1" conn ...
- WCF与Web API 区别(应用场景)
Web api 主要功能: 支持基于Http verb (GET, POST, PUT, DELETE)的CRUD (create, retrieve, update, delete)操作 请求的回 ...
- linux process 相关命令
1.显示指定用户信息:ps -u root 2.显示所有进程信息,连同命令行:ps -ef 3. ps 与grep 常用组合用法,查找特定进程:ps -ef|grep ssh 4. 把所有进程显示出来 ...