javascript - 捕获网页上的签名(通过平板电脑屏幕)

标签 javascript php html json

我正在尝试编写一个简短的代码来通过网页上的平板电脑屏幕捕获签名。但是,我无法获取捕获该签名的区域。

我正在使用的代码是我从其他有效的地方借来的:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Simon's Timesheet Signature Capture Test Page</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/south-street/jquery-ui.css" rel="stylesheet">
<link href="/usr/share/javascript/jquery/jquery.signature.css" rel="stylesheet">
<style>
body > iframe { display: none; }
.kbw-signature { width: 400px; height: 200px; }
</style>
<!--[if IE]>
<script src="js/excanvas.js"></script>
<![endif]-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="/usr/share/javascript/jquery/jquery.signature.js"></script>
<script>
$(function() {
    $('#sig').signature();
    $('#clear').click(function() {
        $('#sig').signature('clear');
    });
    $('#json').click(function() {
        alert($('#sig').signature('toJSON'));
    });
    $('#svg').click(function() {
        alert($('#sig').signature('toSVG'));
    });
});
</script>
</head>
<body>
<h1>jQuery UI Signature Basics v18.5.2018</h1>
<p>This page demonstrates the very basics of the
    <a href="http://keith-wood.name/signature.html">jQuery UI Signature plugin</a>.
    It contains the minimum requirements for using the plugin and
    can be used as the basis for your own experimentation.</p>
<p>For more detail see the <a href="http://keith-wood.name/signatureRef.html">documentation reference</a> page.</p>
<p>Default signature:</p>
<div id="sig"></div>
<p style="clear: both;"><button id="clear">Clear</button> 
    <button id="json">To JSON</button> <button id="svg">To SVG</button></p>
</body>
</html>

我怀疑它与 jquery 的链接有关,除非有人可以看到其他明显明显的东西。 (我对此很陌生)

有谁能引导我走向正确的方向吗?

谢谢。

最佳答案

试试这个...

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Simon's Timesheet Signature Capture Test Page</title>
    <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/south-street/jquery-ui.css"
      rel="stylesheet">
<link href="../js/jquery.signature.css" rel="stylesheet">
<style>
    body > iframe {
        display: none;
    }

    .kbw-signature {
        width: 400px;
        height: 200px;
    }
</style>
<!--[if IE]>
<script src="../js/excanvas.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="../js/jquery.signature.js"></script>
<script src="../js/jquery.ui.touch-punch.min.js"></script>
</head>
<body>
<h1>jQuery UI Signature Basics v18.5.2018</h1>
<p>This page demonstrates the very basics of the
    <a href="http://keith-wood.name/signature.html">jQuery UI Signature plugin</a>.
It contains the minimum requirements for using the plugin and
can be used as the basis for your own experimentation.</p>
<p>For more detail see the <a href="http://keith-wood.name/signatureRef.html">documentation reference</a> page.</p>
<p>Default signature:</p>
<div id="sig"></div>
<p style="clear: both;">
    <button id="clear">Clear</button>
    <button id="json">To JSON</button>
    <button id="svg">To SVG</button>
</p>
<script>
    $(document).ready(function () {
        $('#sig').signature();
    $('#clear').click(function () {
        $('#sig').signature('clear');
    });
    $('#json').click(function () {
        alert($('#sig').signature('toJSON'));
    });
    $('#svg').click(function () {
        alert($('#sig').signature('toSVG'));
    });
});
</script>
</body>
</html>

有几件事。我已将 googleapi 调用更改为 https 而不是 http。这有助于那些对混合内容易怒的浏览器。

签名的代码现在也位于底部,因此这应该确保 #sig div 位于附加到它的代码之前。文档就绪功能也对此有所帮助。

忽略我的 ../js/的签名。我就是这么放的。请参阅上面关于查看页面源代码以查看该文件是否实际可用的评论。

关于javascript - 捕获网页上的签名(通过平板电脑屏幕),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50400100/

相关文章:

php - strip_tags : strip off the messy tags and styles

javascript - Notification.requestPermission 在 Mac 版本的 Safari 中抛出错误

javascript - 无法使用 node.js 和 express 从网页收集用户输入

javascript - 通过指定替换函数使用 JSON.stringify() 函数

javascript - 如何在单击任务时为其添加下划线并将其保存到数据库

javascript - 如何在 JavaScript 中获取数字的 ASCII?

Javascript:从 HTML 输入返回值的问题

php - 带有 ñ 或重音符号的友好 Url 问题字符串

php - 在将它们发布到数据库之前,我尝试将所有链接更改为 nofollow 等

javascript - 如何分别对齐两个跨度元素但在同一行