scanBatch.html 929 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <style>
  6. html,body { width: 100%; height: 100%; overflow: hidden; margin: 0; padding: 0; }
  7. textarea {
  8. width: 99%;
  9. height: 99%;
  10. margin: 0;
  11. padding:10px;
  12. box-sizing: border-box;
  13. border: 1px solid #dcdfe6;
  14. }
  15. </style>
  16. <title></title>
  17. </head>
  18. <body>
  19. <textarea id="scanVal" onkeydown="myFunction(event)" placeholder="请扫描单个或多个监管码"></textarea>
  20. </body>
  21. <script type="text/javascript">
  22. // 自动聚焦
  23. document.getElementById("scanVal").focus();
  24. function myFunction(event){
  25. var x = event.keyCode;
  26. if (x == 13) { // 13 是 回车 键
  27. console.log ("你按下了回车键!");
  28. window.parent.postMessage({ //参数是对象
  29. cmd: '***',
  30. params: {
  31. success: true
  32. }
  33. }, '*');
  34. }
  35. }
  36. </script>
  37. </html>