Colleagues have developed a Firefox plugin, used to read card information contactless card, but the page will not call, after the data found in fact quite simple, that is, more pits.
<title> Testing </title>
<embed id= "plugin" type= "Application/intime-plugin" style= "display:block;width:50%;height:100px"; ></embed>
<script language= "JavaScript" >
var plugin = document.getElementById ("plugin");
function Dotest () {
Plugin.getcard ();
card = Plugin.getcard;
alert (card);
}
</script>
<body>
<form name= "FormName" >
<input type= "button" onclick= "Dotest ()" value= "read card"/>
</form>
</body> embed is the loading of Plug-ins, Getcard () is the operation of reading cards, Getcard is to obtain card number information.
1. Even with jquery, you can't use jquery's selector when locating the DOM element, otherwise you can't read it.
2, the plugin can not be hidden, if it is hidden after the expiration, so display:none, or hide () is not desirable.
Original reference from Web Development network: http://www.software8.co/wzjs/
This is written as a plug-in to facilitate the use of card reader operation.
(function ($) {
$.FN.SWIPECPU = function (params) {
var defaults = {
Trigger:false
};
$.extend (defaults, params);
var ele = $ (this);
Height 1px,width 0px compress the plugin in the position of the page as far as possible, cannot set to 0, also cannot set the display none, will cause the plugin invalidation;
Ele.after ("<embed id=\" plugin-cpu-read\ "type=\" application/intime-plugin\ "style=\" display:block;height:0px; Width:0px;\ ">");
var plugin = document.getElementById ("Plugin-cpu-read");
Plugin.getcard ();
Although the attribute is defined in the plug-in as a string, the object is passed, so you can only copy it to the text box, take the value, and then intercept the
var cardno = Plugin.getcard;
Ele.val (Cardno);
Cardno = Substrcard ($ (this). Val ());
Ele.val (Cardno);
$ ("#plugin-cpu-read"). Remove ();
Whether a carriage return event needs to be triggered
if (Defaults.trigger) {
var event = $. Event ("KeyUp");
Event.keycode = 13;
Event.which = 13;
Ele.trigger (event);
}
};
}) (JQuery);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.