Sampson-Li
Sampson.Li学习经验总结博客 学历代表过去,能力代表现在.学习力代表未来!
分享一个百度写字版的demo,不知道怎么了,现在百度木有了,估计是用户体验不是很好吧.木有太多人用. 源码附加/Files/liguanghui/baiduWrite.rar

<html> 

<head> 
<meta http-equiv="Content-Type" content="text/html;charset=gb2312"> 
<title>百度在线手写板代码</title> 
<style> 
#sx{color:#00C;text-decoration:underline;cursor:pointer;} 
</style> 
</head> 
<body> 
<form name="f" action="s"> 
<input type="text" name="wd" id="kw" maxlength="100"> 
<input type="submit" value="" id="su"> 
<span id="sx">手写</span> 
</form> 
<script> 
var w = window,d = document,n = navigator,k = d.f.wd 
if (w.attachEvent) { 
w.attachEvent("onload", function() {k.focus();}) 
} else { 
w.addEventListener('load', function() {k.focus()},true) 
}; 
var hw = {}; 
hw.i = d.getElementById("sx"); 
var il = false; 
if (/msie (\d+\.\d)/i.test(n.userAgent)) { 
hw.i.setAttribute("unselectable", "on") 
} else { 
var sL = k.value.length; 
k.selectionStart = sL; 
k.selectionEnd = sL 
hw.i.onclick = function(B) { 
var B = B || w.event; 
B.stopPropagation ? B.stopPropagation() : (B.cancelBubble = true); 
if (d.selection && d.activeElement.id && d.activeElement.id == "kw") { 
hw.hasF = 1 
} else { 
if (!d.selection) { 
hw.hasF = 1 
if (!il) { 
var A = d.createElement("script"); 
A.setAttribute("src", "baidu_input.js"); 
d.getElementsByTagName("head")[0].appendChild(A); 
il = true; 
}; 
</script> 
</body> 
</html> 
posted on 2011-11-04 09:56  Sampson  阅读(342)  评论(0编辑  收藏  举报