js选中文字分享新浪微博
- <style>
- .img_sina_share{display:none; position:absolute; cursor:pointer;}
- </style>
- <img id="imgSinaShare" class="img_sina_share" title="将选中内容分享到新浪微博" src="http://simg.sinajs.cn/blog7style/images/common/share.gif">
- <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 : "未命名页面";
- if (txt) {
- window.open('http://v.t.sina.com.cn/share/share.php?title=' + txt + '→来自页面"' + title + '"的文字片段&url=' + window.location.href);
- }
- };
- }(eleImgShare);
- </script>
- <h1>木兰诗</h1>
- 唧唧复唧唧,木兰当户织,不闻机杼声,惟闻女叹息。问女何所思,问女何所忆,女亦无所思,女亦无所忆。昨夜见军帖,可汗大点兵。军书十二卷,卷卷有爷名,阿爷无大儿,木兰无长兄,愿为市鞍马,从此替爷征。
- 东市买骏马,西市买鞍貉,南市买辔头,北市买长鞭。旦辞爷娘去,暮至黄河边。不闻爷娘唤女声,但闻黄河流水鸣溅溅。但辞黄河去,暮宿黑山头。不闻爷娘唤女声,但闻燕山胡骑鸣啾啾。
- 万里赴戎机,关山度若飞。朔气传金析,寒光照铁衣。将军百战死,壮士十年归。
- 归来见天子,天子坐明堂。策勋十二转,赏赐百千强。可汗问所欲,木兰不用尚书郎。愿驰千里足,送儿还故乡。
- 爷娘闻女来,出郭相扶将。阿姊闻妹来,当户理红妆。小弟闻姊来,磨刀霍霍向猪羊。开我东阁门,坐我西阁床。脱我战时袍,着我旧时裳。当窗理云鬓,对镜贴花黄。出门看伙伴,伙伴皆惊惶。同行十二年,不知木兰是女郎!
- 雄兔脚扑朔,雌兔眼迷离。双兔傍地走,安能辨我是雄雌。