12345678910111213141516171819202122232425262728293031323334353637383940 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <style>
- html,body { width: 100%; height: 100%; overflow: hidden; margin: 0; padding: 0; }
- textarea {
- width: 99%;
- height: 99%;
- margin: 0;
- padding:10px;
- box-sizing: border-box;
- border: 1px solid #dcdfe6;
- }
- </style>
- <title></title>
- </head>
- <body>
- <textarea id="scanVal" onkeydown="myFunction(event)" placeholder="请扫描单个或多个监管码"></textarea>
- </body>
- <script type="text/javascript">
- // 自动聚焦
- document.getElementById("scanVal").focus();
-
- function myFunction(event){
- var x = event.keyCode;
- if (x == 13) { // 13 是 回车 键
- console.log ("你按下了回车键!");
-
- window.parent.postMessage({ //参数是对象
- cmd: '***',
- params: {
- success: true
- }
- }, '*');
- }
- }
-
- </script>
- </html>
|