简体   繁体   English

通过刷卡进行HTML登录

[英]HTML Login via Card Swipe

I am trying to create an html login page that allows a user to login via a card swipe (with a card reader attached to their computer). 我正在尝试创建一个html登录页面,允许用户通过刷卡(连接到他们的计算机的读卡器)登录。 My thought original thought was to make a hidden text box, put the focus on the hidden text box, and when the card is swiped, the card info goes into the box and submits the form. 我的想法最初的想法是制作一个隐藏的文本框,将焦点放在隐藏的文本框中,当刷卡时,卡信息进入框并提交表单。

Problems: 1. I keep getting a JS error when I try xx.focus() on a hidden text box. 问题:1。当我在隐藏文本框上尝试xx.focus()时,我一直收到JS错误。 2. I made the textbox visible, but set its height and width to 1px. 2.我使文本框可见,但将其高度和宽度设置为1px。 You can still see the cursor blinking in the textbox though. 您仍然可以看到光标在文本框中闪烁。

Question: Anybody have a great way of implementing this idea? 问:任何人都有很好的方式来实现这个想法?

If you don't want the user to ever see the textbox, you can use the old CSS " hiding stuff off of the screen " trick. 如果你不希望用户看到文本框,你可以使用旧的CSS“ 隐藏屏幕外的东西 ”技巧。 Just set an absolute position to the left or right that no screen will be able to display. 只需设置左侧或右侧的绝对位置,即无法显示任何屏幕。 For example (pulled from the referenced page): 例如(从引用的页面中拉出):

.offscreen {
    position: absolute;
    left: -999em;
}

Short answer: 简短回答:

Yes, an input hidden via css (not type="hidden" ) is actually the only way to go. 是的,通过css隐藏的input (不是type="hidden" )实际上是唯一的方法。

Why? 为什么?

I've had to deal with keyboard emulation card readers in web browsers in the past. 我过去不得不在网络浏览器中处理键盘仿真卡读卡器。 I've tried pure javascript solutions (eg just listening to keypress events on the DOM), however what I've experienced is that many times cards can have control characters in them that the browser reacts to. 我已经尝试过纯粹的javascript解决方案(例如,只是在DOM上监听按键事件),但是我经历过的是很多时候卡片中都有控制字符,浏览器会对其做出反应。

Sounds like you are close. 听起来你很近。 You could also do a quick Flash app where soem additional options come up. 你也可以做一个快速的Flash应用程序,其中会出现其他选项。 As for the html one try to set stuyle of text box color / padding to move the cursor frm view 至于html,尝试设置文本框颜色/填充的stuyle来移动光标frm视图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM