gpt4 book ai didi

javascript - 如何将签名保存到本地驱动器

转载 作者:行者123 更新时间:2023-12-03 11:07:58 25 4
gpt4 key购买 nike

我使用下面的代码来获取签名,我想在单击按钮时将签名保存到本地驱动器。请指导我如何从下面的代码中实现。

代码来源: https://codeload.github.com/thomasjbradley/signature-pad/legacy.zip/master

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Require a Drawn Signature · Signature Pad</title>
<style>
body { font: normal 100.01%/1.375 "Helvetica Neue",Helvetica,Arial,sans-serif; }
</style>
<link href="../assets/jquery.signaturepad.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>

<script>
function signatureSave() {
var canvas = document.getElementById("newSignature");// save canvas image as data url (png format by default)
var dataURL = canvas.toDataURL("image/png");

document.getElementById("saveSignature").src = dataURL;
};
</script>
</head>
<body>
<form method="post" action="" class="sigPad">
<label for="name">Print your name</label>
<input type="text" name="name" id="name" class="name">
<p class="drawItDesc">Draw your signature</p>
<ul class="sigNav">
<li class="drawIt"><a href="#draw-it" >Draw It</a></li>
<li class="clearButton"><a href="#clear">Clear</a></li>
</ul>
<div class="sig sigWrapper">
<div class="typed"></div>
<canvas class="pad" width="198" id="newSignature" height="55"></canvas>
<input type="hidden" name="output" class="output">
</div>
<button type="button" onClick="signatureSave()">Save signature</button>

<img id="saveSignature" alt="Saved image png"/>
</form>

<script src="../jquery.signaturepad.js"></script>
<script>
$(document).ready(function() {
$('.sigPad').signaturePad({drawOnly:true});
});
</script>
<script src="../assets/json2.min.js"></script>
</body>

最佳答案

localStorage.setItem("signature", dataURL);

var signature = localStorage.getItem("signature");

关于javascript - 如何将签名保存到本地驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27752038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com