新媒体-合同签约,CA签约

signature.html 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>手写签名</title>
  8. <link rel="stylesheet" href="./common/reset.css">
  9. <script type="text/javascript" src="./common/jquery-2.1.0.js"></script>
  10. <script type="text/javascript" src="./common/jq-signature.js"></script>
  11. <script type="text/javascript">
  12. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  13. window.onresize = function(){
  14. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  15. }
  16. </script>
  17. <style>
  18. .buttonDiv{
  19. display: flex;
  20. align-items: center;
  21. justify-content: space-around;
  22. margin-top: 0.6rem;
  23. }
  24. .buttonDiv button{
  25. width: 1rem;
  26. line-height: 0.3rem;
  27. border: none;
  28. background: #e9524a;
  29. color: #ffffff;
  30. border-radius: 0.3rem;
  31. }
  32. #clearBtn{
  33. background: #8e8e94;
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <!--签名区域-->
  39. <div class="js-signature"
  40. data-width="600"
  41. data-height="200"
  42. data-border="1px solid #ededed"
  43. data-background="#fff"
  44. data-line-color="#000"
  45. data-auto-fit="true">
  46. </div>
  47. <div class="buttonDiv">
  48. <button id="clearBtn" onclick="clearCanvas();">清除</button>
  49. <button id="saveBtn" onclick="saveSignature();" disabled>保存</button>
  50. </div>
  51. <div id="signature"></div>
  52. <script>
  53. $(function () {
  54. $('.js-signature').jqSignature();
  55. $('.js-signature').on('jq.signature.changed', function() {
  56. $('#saveBtn').attr('disabled', false);
  57. });
  58. document.getElementsByClassName("js-signature")[0].addEventListener('touchstart', startEventHandler, {passive: false});
  59. function startEventHandler(event) {
  60. event.preventDefault();
  61. }
  62. })
  63. function clearCanvas() {
  64. // $('#signature').html('<p><em>Your signature will appear here when you click "Save Signature"</em></p>');
  65. $('.js-signature').jqSignature('clearCanvas');
  66. $('#saveBtn').attr('disabled', true);
  67. }
  68. function saveSignature() {
  69. $('#signature').empty();
  70. var dataUrl = $('.js-signature').jqSignature('getDataURL');
  71. var img = $('<img>').attr('src', dataUrl);
  72. // $('#signature').append($('<p>').text("Here's your signature:"));
  73. $('#signature').append(img);
  74. }
  75. </script>
  76. </body>
  77. </html>