zoukankan      html  css  js  c++  java
  • 微博划词转发

    var miniBlogShare = function() {
    //指定位置显示的分享图标按钮
    $('<img id="imgSinaShare" class="img_share" title="将选中内容分享到新浪微博" src="http://www.sprityaoyao.org/content/templates/ljie/images/sina_share.gif" /><img id="imgQqShare" class="img_share" title="将选中内容分享到腾讯微博" src="http://www.sprityaoyao.org/content/templates/ljie/images/tt_share.png" />').appendTo('body');

    //图标样式
    $('.img_share').css({
    display : 'none',
    position : 'absolute',
    cursor : 'pointer'
    });

    //实现选中文字
    var funGetSelectTxt = function() {
    var txt = '';
    if(document.selection) {
    txt = document.selection.createRange().text;
    } else {
    txt = document.getSelection();
    }
    return txt.toString();
    };

    //实现选中文字后显示微博分享图标
    $('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');
    }
    });
    function getParamsOfShareWindow(width, height) {
    //弹窗代码
    return ['toolbar=0,status=0,resizable=1,width=' + width + ',height=' + height + ',left=', (screen.width - width) / 2, ',top=', (screen.height - height) / 2].join('');
    }

    //点击新浪微博
    $('#imgSinaShare').click(function() {
    var txt = funGetSelectTxt(), title = $('title').html();
    var params = getParamsOfShareWindow(607, 523);
    if (txt) {
    window.open('http://v.t.sina.com.cn/share/share.php?title=' + txt + ' —— 转载自:' + title + '&url=' + window.location.href,'share',params);
    }
    });

    //点击腾讯微博
    $('#imgQqShare').click(function() {
    var txt = funGetSelectTxt(), title = $('title').html();
    var params = getParamsOfShareWindow(642, 468);
    if (txt) {
    window.open('http://v.t.qq.com/share/share.php?title=' + encodeURIComponent(txt + ' —— 转载自:' + title) + '&url=' + window.location.href,'share',params);
    }
    });
    }();
       //实现选中文字
    var funGetSelectTxt = function() {
    var txt = '';
    if(document.selection) {
    txt = document.selection.createRange().text;
    } else {
    txt = document.getSelection();
    }
    return txt.toString();
    };
    
    
    选中的文字
  • 相关阅读:
    cf 786B. Legacy(线段树区间建图)
    cf 1416D. Graph and Queries (生成树重构+线段树维护dfs序)
    cf 1437E. Make It Increasing
    cf 1434D. Roads and Ramen (树上最长偶权链)
    cf 1413C (贪心排序+双指针)
    cf 1421E. Swedish Heroes (dp)
    CF1428 F.Fruit Sequences
    11.Redis详解(十一)------ 过期删除策略和内存淘汰策略
    10.Redis详解(十)------ 集群模式详解
    9.Redis详解(九)------ 哨兵(Sentinel)模式详解
  • 原文地址:https://www.cnblogs.com/jinbiao/p/2320828.html
Copyright © 2011-2022 走看看