网上下载的一个电子签名代码,可以在电脑和手机上正常使用,但是如何将生成的签名图片保存到本地文件中,并关闭签字页面,转到其他页面(如2.htm,我从1.htm打开),请帮忙看一下,在哪里加上保存代码,谢谢。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" c />
<title></title>
<script src="js/mui.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet" />
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/jSignature.min.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="js/flashcanvas.js"></script>
<![endif]-->
</head>
<body>
<h3>请在下方签名</h3>
<div id="signature" style="height: 100%;"></div>
<br>
<input id="clear" type="button" value="清除">
<input id="export" type="button" value="输出图片">
<input id="save" type="button" value="保存base64">
<div id="pic" />
<p id="base" style="width:100%;"></p>
<script type="text/javascript" charset="utf-8">
mui.plusReady(function() {
plus.screen.lockOrientation('landscape-secondary');
});
$(document).ready(function() {
$("#signature").jSignature({
width: '100%',
height: '100%',
UndoButton: true,
sizeRatio: 1,
color: "#000",
"background-color": "#fff",
"decor-color": "rgba(20,0,0,0)", //这里将颜色设置为透明
lineWidth: 2,
})
});
document.getElementById("clear").addEventListener('tap', function() {
$("#signature").jSignature("reset");
$("#pic")[0].innerHTML = '';
});
document.getElementById("save").addEventListener('tap', function() {
var datapair = $("#signature").jSignature("getData", "image");
var array = datapair.splice(",");
mui.toast(array[1]);
});
document.getElementById("export").addEventListener('tap', function() {
var datapair = $("#signature").jSignature("getData", "image");
var i = new Image();
i.src = "data:" + datapair[0] + "," + datapair[1];
$(i).appendTo($("#pic"));
});
</script>
</body>
</html>