javascript - how to include js file in an html file? -
i want implement virtual keyboard in project. never included before referred link , tried below:
<head> <script type="text/javascript" src="vkboards.js"></script> <script> // minimal callback function: function keyb_callback(char) { // bind vkeyboard <textarea> // id="textfield": var text = document.getelementbyid("textfield"), val = text.value; switch(ch) { case "backspace": var min=(val.charcodeat(val.length - 1) == 10) ? 2 : 1; text.value = val.substr(0, val.length - min); break; case "enter": text.value += "\n"; break; default: text.value += ch; } } </script> </head>
in style:
#keyboard { width:800px; height:400px; background-color:#f2f3f1; margin:1px auto; border-radius:25px; box-shadow:5px 5px 5px grey; }
in body:
<body onload="new vkeyboard("keyboard", keyb_callback);"> <textarea id="textfield" rows="1" cols="25"></textarea> <div id="keyboard"></div> </div> </body>
i tried this,searched net nothing made work. please go through code , me correct it. appreciated.
you might try changing quotes around keyboard single quotes this.
<body onload="new vkeyboard('keyboard', keyb_callback);">
Comments
Post a Comment