WordPress will forward selected text to Sina Weibo

Source: Internet
Author: User
Tags ming jquery library wordpress blog

The method of implementation is also simple and requires only two steps:

1, the introduction of jquery, I believe that most WordPress blog has introduced jquery, it can be a direct second step.

2, at the bottom of the page, or more specifically, in the introduction of the JQuery library after adding such a section of JS, you can see the same effect as the site.

The code is as follows Copy Code

var miniblogshare = function () {
Specify location in node
$ ('
Default Style
$ ('. Img_share '). CSS ({
Display: ' None ',
Position: ' Absolute ',
Cursor: ' pointer '
});

Select text
var fungetselecttxt = function () {
var txt = ';
if (document.selection) {
txt = Document.selection.createRange (). text;
} else {
txt = document.getselection ();
}
return txt.tostring ();
};

Show microblogging icon when text is selected
$ (' html,body '). MouseUp (function (e) {
if (e.target.id = = ' Imgsinashare ' | | | e.target.id = = ' Imgqqshare ') {
Return
}
E = e | | window.event;
var txt = fungetselecttxt (),
SH = Window.pageyoffset | | Document.documentElement.scrollTop | | Document.body.scrollTop | | 0,
left = (e.clientx-40 < 0)? E.clientx + 20:e.clientx-40,
top = (e.clienty-40 < 0)? E.clienty + sh + 20:e.clienty + sh-40;
if (TXT) {
$ (' #imgSinaShare '). CSS ({
Display: ' Inline ',
Left:left,
Top:top
});
$ (' #imgQqShare '). CSS ({
Display: ' Inline ',
Left:left + 30,
Top:top
});
} else {
$ (' #imgSinaShare '). CSS (' Display ', ' none ');
$ (' #imgQqShare '). CSS (' Display ', ' none ');
}
});

Click on Sina Weibo
$ (' #imgSinaShare '). Click (function () {
var txt = fungetselecttxt (), title = $ (' title '). HTML ();
if (TXT) {
window.open (' http://v.t.sina.com.cn/share/share.php?title= ' + txt + '--reprinted from: ' + title + ' &url= ' + window.location.hre f);
}
});

Click on Tencent Weibo
$ (' #imgQqShare '). Click (function () {
var txt = fungetselecttxt (), title = $ (' title '). HTML ();
if (TXT) {
window.open (' http://v.t.qq.com/share/share.php?title= ' + encodeuricomponent (txt + '--reprinted from: ' + title) + ' &url= ' + wind OW.LOCATION.HREF);
}
});
}();


Full instance

The code is as follows Copy Code

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<meta http-equiv= "description" content= "page selected text to share to Sina Weibo» Rok Zhang Xinsen xu-Xin space-xin Life"/>
<meta name= "description" content= "Rok Zhang Xinsen Xu Web Front-End Learning Example page"/>
<meta name= "keywords" content= "rok Zhang Xinsen Xu, Rok Zhang Xinsen xu-Xin space-Xin life, Web front-end, CSS, JQuery, JavaScript, demo page"/>
<meta name= "Author" content= "Rok Zhang Xinsen Xu, zhangxixnu"/>
<title> page selected text to share to Sina Weibo» Rok Zhang Xinsen-Xin space-Xin Life </title>
<link rel= "stylesheet" href= ". /css/demo.css "type=" Text/css "/>
<style>
. img_sina_share{display:none; position:absolute; cursor:pointer;}
</style>

<body>
<div id= "Header" >
<a href= "http://www.111cn.net/" class= "logo" title= "Back to Xin space-Xin Life Home" >

</a>
</div>
<div id= "Main" >
<div id= "Body" class= "Light" >
<div id= "Content" class= "Show" >
<div class= "article_new" ><a href= "http://www.111cn.net/wordpress/?p=1428" > Back to related articles»</a></div >
<div class= "Demo" >
<div id= "testcontent" class= "F14" >
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
Recently infatuated with the "Palace Lock Heart Jade" This TV series, really is particularly good-looking, let me every night to sleep until after 12 o'clock, but there is a small discovery, is the palace and Meteor Garden as if, hehe, can be said to be the ancient costume version of "Meteor Garden" </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
1. Do not say specific things, the characters, has been with the Qing Chuan to bully the eight elder brother is the ancient version of the temple, and nine elder brother Ten elder brother is F3, four elder brother played the role of that Flower Ze class. There is a general small image of the vegetarian vs that Cedar good friend (forgot what to call the following with L instead), Xiaochun vs Qinghe, old bullying Qingchuan and that do not know what to call the Gong Maid vs the two gold Digger women 、、、、 </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr> Specific Event:</p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
1. Offended eight the elder maid was driven out of the palace vs offended F4 's classmates were driven out of school </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
2. Qingchuan for the element words offend eight elder brother vs Cedar vegetables for her friend L offended F4</p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
3. Offend the eight elder brother after everyone dare not sympathize with the Qing Chuan, Ching Chuan kneeling chain Element said also dared not come forward, but secretly to clear Sichuan steamed bread vs cedar food offended F4
L Dare not approach him, but secretly message comfort </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
4. The devil arranged the rape scene, a four elder brother rescued a flower ze class rescue, and then staged how to let the tears do not flow out of the play Code </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
5. Four elder brother's piano vs. the music of the flower-ze type </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
6. In the Palace of fine Kunaka by the four elder brother rescued, four elder brother and eight elder brother choke sound, Sifojin with Qing Chuan to freshen up vs Shanshan and Qinghe is chasing Flower Ze class rescue, class also with Dao Ming Temple choke a bit, Cany Hall static with Cedar food to freshen up </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
7. Hear Qingchuan and four age rumors eight elder brother angry find Qingchuan and strong kissed her see Qingchuan cry and in turn comfort her vs Dao Ming Temple strong Kiss Cedar </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
8. Qingchuan for and eight elder brother struggle to train their physical strength to eat + running vs Cedar meal + running. And there are "I won't give in" lines </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
9. Four the elder brother and the DAO Ming Temple all said "a good news a bad news" "Endurance wins respect" "doubles against You" </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
10. Fight eight the elder brother fell in love with the Khakawa temple fell in love with the cedar, and the heroine was dismissive, fell in love with others; Of course, in contact with the other side </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
11. Qingchuan spent the night at the Crown prince and changed his clothes to be misunderstood vs. cedar and foreigners in the hotel encounter. When they almost got hurt and there was a moving line, "If you just say I believe," </p>
<p>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>&nbsp;<wbr></wbr>
Oh, there are a lot of similarities, too late brain began to make a confused not to say, this is certainly not criticized, because I really like the palace of this TV series, just bored casually listed, entertainment just. </p>
</div>

</div>
</div>
</div>
</div>
<div id= "Footer" >
Designed &amp; Powerd by <a href= "http://www.111cn.net/" >hzhuti</a><br/>
Copyright© rok Zhang Xinsen-xin Room-Xin Life <br>
<a href= "http://www.111cn.net/" target= "_blank" > E ICP 备 No. No. 09015569 </a>
</div>
<script>
var eleimgshare = document.getElementById ("Imgsinashare");

var $sinaMiniBlogShare = function (Eleshare, Elecontainer) {
var eletitle = document.getElementsByTagName ("title") [0];
Elecontainer = Elecontainer | | Document
var fungetselecttxt = function () {
var txt = "";
if (document.selection) {
txt = Document.selection.createRange (). text; Ie
} else {
txt = document.getselection ();
}
return txt.tostring ();
};
Elecontainer.onmouseup = function (e) {
E = e | | window.event;
var txt = fungetselecttxt (), sh = Window.pageyoffset | | Document.documentElement.scrollTop | | Document.body.scrollTop | | 0;
var left = (e.clientx-40 < 0)? E.clientx + 20:e.clientx-40, top = (e.clienty-40 < 0)? E.clienty + sh + 20:e.clienty + sh-40;
if (TXT) {
EleShare.style.display = "inline";
EleShare.style.left = left + "px";
EleShare.style.top = top + "px";
} else {
EleShare.style.display = "None";
}
};
Eleshare.onclick = function () {
var txt = fungetselecttxt (), title = (Eletitle && eletitle.innerhtml)? eletitle.innerhtml: "Unnamed page";
if (TXT) {
window.open (' http://v.t.sina.com.cn/share/share.php?title= ' + txt + ' → from the page "' + title + '" Text fragment &url= ' + WINDOW.LOCATION.HREF);
}
};
} (Eleimgshare);
</script>
</body>

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.