手写板 (调用百度接口)

 1 <!doctype html>
 2 <html>
 3 <head>
 4 <title>落日赌城</title>
 5 <style>
 6 #sx{color:#00C;text-decoration:underline;cursor:pointer;}
 7 </style>
 8 </head>
 9 <body>
10 <form name="f" action="s">
11 <input type="text" name="wd" id="kw" maxlength="100">
12 <input type="submit" value="" id="su">
13 <span id="sx">手写</span>
14 </form>
15 <script> 
16 var w = window,d = document,n = navigator,k = d.f.wd
17 if (w.attachEvent) {
18     w.attachEvent("onload", function() {k.focus();})
19 } else {
20     w.addEventListener('load', function() {k.focus()},true)
21 };
22 var hw = {};
23 hw.i = d.getElementById("sx");
24 var il = false;
25 if (/msie (\d+\.\d)/i.test(n.userAgent)) {
26     hw.i.setAttribute("unselectable", "on")
27 } else {
28     var sL = k.value.length;
29     k.selectionStart = sL;
30     k.selectionEnd = sL
31 }
32 hw.i.onclick = function(B) {
33     var B = B || w.event;
34     B.stopPropagation ? B.stopPropagation() : (B.cancelBubble = true);
35     if (d.selection && d.activeElement.id && d.activeElement.id == "kw") {
36         hw.hasF = 1
37     } else {
38         if (!d.selection) {
39             hw.hasF = 1
40         }
41     }
42     if (!il) {
43         var A = d.createElement("script");
44         A.setAttribute("src", "http://www.baidu.com/hw/hwInput.js"); 
45         d.getElementsByTagName("head")[0].appendChild(A);
46         il = true;
47     }
48 }; 
49 </script>
50 <br />
51 
52 </body>
53 </html>
以大多数人的努力之低,根本轮不到拼天赋。
原文地址:https://www.cnblogs.com/jrsnd/p/js.html