亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JavaScript實(shí)現(xiàn)選中文字提示新浪微博分享效果

 更新時(shí)間:2017年06月15日 10:16:07   作者:liguangsunls  
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)選中文字提示新浪微博分享效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了JS新浪微博分享功能,供大家參考,具體內(nèi)容如下

<!DOCTYPE html>
<html xmlns:wb="http://open.weibo.com/wb">
<head>
  <meta charset="utf-8">
  <title>javaScript實(shí)現(xiàn)選中文字提示新浪微博分享的效果</title>
  <style type="text/css">
   #div1{ position: absolute; left: 0;top: 0; display: none;}
  </style>
</head>
<body>
  <p id="txt">
    一直對(duì)json的使用方法迷迷糊糊,知道一些簡(jiǎn)單的使用方法,有時(shí)用起來非常easy把自己搞混。今天專門查了一下相關(guān)的JSON的資料及使用方法,總結(jié)記錄下來。JSON并非一種編程語言。能夠理解成它是一種數(shù)據(jù)格式。盡管具有同樣的語法形式。可是JSON并不屬于JavaScript。并且。并非全部的JavaScript才使用JSON,非常多編程語言都有針對(duì)JSON的解析器和序列化器。JSON的語法能夠表示三種類型值:
  </p>
  <div id="div1"><img src="https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=163431486,1136892253&fm=58"></div>
  <script type="text/javascript">
    window.onload=function(){
      function selectText(){
        if(document.selection){
        //兼容ie
          return document.selection.createRange().text;
        } else{
        //標(biāo)準(zhǔn)的獲取方法
          return window.getSelection().toString();
        }
      }
      var oTxt = document.getElementById('txt');
      var oDiv = document.getElementById('div1');

      oTxt.onmouseup = function(ev){
        var ev =ev||window.event;
        var top = ev.clientY;
        var left = ev.clientX;
        if(selectText().length>10){
          console.log(selectText())
          setTimeout(function(){
            oDiv.style.display = 'block';
            oDiv.style.left =left+'px';
            oDiv.style.top = top +'px';
          },1000)
        } else{
          oDiv.style.display = 'none';
        }
      };
      oTxt.onclick =function(ev){
        var ev =ev||window.event;
        ev.cancelBubble = true;
      }
      document.onclick = function(){
        oDiv.style.display = 'none';
      };
      //點(diǎn)擊分享的實(shí)現(xiàn)
      oDiv.onclick = function(){
        window.location.+selectText()+window.location.href;
      }
    }
  </script>

</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論