I recently noticed that Sina Blog has a small function, that is, a small image will appear when you select a text section. Click this image to send the selected content to Sina Weibo, on the Rise of the moment, I wrote a Demo last night and played it. The code is super simple and not optimized. If you are interested, you can improve it on your own.
The principle is very simple. first obtain the selected text with the mouse, then call the page provided by Sina Blog, and pass the text as a parameter.
The Code is as follows:
<Html xmlns =" http://www.w3.org/1999/xhtml "> <Head runat =" server "> <title> </title> <style type =" text/css ">. tooltip {width: 120px; height: 23px; line-height: 23px; background-color: # CCCCCC ;}. tooltip a {color: #333333; display: block; font-size: 12px; font-weight: bold; text-indent: 10px ;}</style> <script src =" http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js "> </Script> <script type =" text/javascript ">$ (function () {$ (" # blogContent "). mouseup (function (e) {var x = 10; var y = 10; var r = ""; if (document. selection) {r = document. selection. createRange (). text;} else if (window. getSelection () {r = window. getSelection ();} if (r! = "") {Var bowen = "sent to Sina Weibo "; var tooltip = "<div id = 'tooltip 'class = 'tooltip'> <a onclick = ask ('" + r + "')> "+ bowen +" </a> </div> "; $ (" body "). append (tooltip); $ ("# tooltip" ).css ({"top": (e. pageY + y) + "px", "left": (e. pageX + x) + "px", "position": "absolute "}). show ("fast ");}}). mousedown (function () {$ ("# tooltip "). remove () ;}) function ask (r) {if (r! = "") {Window. open (' http://v.t.sina.com.cn/share/share.php?searchPic=false&title= '+ R +' & url = http://www.nowwamagic.net&sourceUrl=http%3A%2F%2Fblog.sina.com.cn&content=utf-8&appkey=1617465124 ',' _ Blank ', 'height = 515, width = 598, toolbar = no, menubar = no, scrollbars = auto, resizable = yes, location = no, status = yes ') ;}}</script>
That's easy. You can try it on your own. Of course, you can also perform other operations to obtain the selected text. Here, we just call the Sina page. If you are interested, you can create your own applications.