菜单

Javascript将内容分享到各大社交平台网址的代码计算

2019年8月17日 - jQuery

以上代码经净化管理后:

 代码如下

主导的代码(Javascript):

用户复制小说时自动抬高连接

切实的应用方法如下(完整代码):

 代码如下

function sharePlugin(name,img,title){
 var purl=encodeURIComponent(document.location.href);
 switch(name){
  case 'sina':
   var url='http://service.t.sina.com.cn/share/share.php?url='+purl+'&appkey=2858164115&title='+encodeURIComponent(""+title)+'&pic='+encodeURIComponent(img)+'&ralateUid=&searchPic=false';//注意这个地方使用了一个appkey,分享到新浪的时候会有一个分享来源,其中的分享来源就取决于这个appkey,你可以根据需要改成自己的appkey
   window.open(url);
  break;
  case 'tqq':
   var url='http://v.t.qq.com/share/share.php?title='+encodeURIComponent(""+title)+'&url='+purl+'&appkey='+encodeURI("8675d8896e054316bc69755118dea3c9")+'&site='+purl+'&pic='+img;
   window.open( url,'转播到腾讯微博','width=700,height=680,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,location=yes,resizable=no,status=no' );
  break;
  case 'kaixin':
   var url='http://www.kaixin001.com/repaste/share.php?rurl='+purl+'&rcontent='+encodeURIComponent(""+title)+'&rtitle='+encodeURIComponent("欣和食与家");
   window.open(url);
  break;
  case 'renren':
   var url='http://share.renren.com/share/buttonshare.do?link='+purl+'&title='+encodeURIComponent(""+title);
   window.open(url);
  break;
  case 'douban':
   var url='http://www.douban.com/recommend/?url='+purl+'&title='+encodeURIComponent(""+title);
   window.open(url);
  break;
  case 'qzone':
   var url='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(""+title)+'&pics='+img;
   window.open(url);
  break;
 }
}

<input type=”button” name=”Submit” onClick=’copyToClipBoard()’
value=”复制专项论题地址,传给QQ/MSN上的管鲍之交”>
<script language=”javascript”>
   function copyToClipBoard(){
    var clipBoardContent=””;
    clipBoardContent+=document.title;
    clipBoardContent+=””;
    clipBoardContent+=this.location.href;
    window.clipboardData.setData(“Text”,clipBoardContent);
   alert(“复制作而成功,请粘贴到您的QQ/MSN上引入给您的相知”);
}
</script>

function sharePlugin(name,img,title){var purl=encodeURIComponent(document.location.href);switch(name){case'sina':var url='http://service.t.sina.com.cn/share/share.php?url='+purl+'&appkey=2858164115&title='+encodeURIComponent(""+title)+'&pic='+encodeURIComponent(img)+'&ralateUid=&searchPic=false';window.open(url);break;case'tqq':var url='http://v.t.qq.com/share/share.php?title='+encodeURIComponent(""+title)+'&url='+purl+'&appkey='+encodeURI("8675d8896e054316bc69755118dea3c9")+'&site='+purl+'&pic='+img;window.open(url,'转播到腾讯微博','width=700,height=680,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,location=yes,resizable=no,status=no');break;case'kaixin':var url='http://www.kaixin001.com/repaste/share.php?rurl='+purl+'&rcontent='+encodeURIComponent(""+title)+'&rtitle='+encodeURIComponent("欣和食与家");window.open(url);break;case'renren':var url='http://share.renren.com/share/buttonshare.do?link='+purl+'&title='+encodeURIComponent(""+title);window.open(url);break;case'douban':var url='http://www.douban.com/recommend/?url='+purl+'&title='+encodeURIComponent(""+title);window.open(url);break;case'qzone':var url='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(""+title)+'&pics='+img;window.open(url);break}}

 代码如下

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>www.phpernote.com</title>
<script language="javascript">
function sharePlugin(name,img,title){var purl=encodeURIComponent(document.location.href);switch(name){case'sina':var url='http://service.t.sina.com.cn/share/share.php?url='+purl+'&appkey=2858164115&title='+encodeURIComponent(""+title)+'&pic='+encodeURIComponent(img)+'&ralateUid=&searchPic=false';window.open(url);break;case'tqq':var url='http://v.t.qq.com/share/share.php?title='+encodeURIComponent(""+title)+'&url='+purl+'&appkey='+encodeURI("8675d8896e054316bc69755118dea3c9")+'&site='+purl+'&pic='+img;window.open(url,'转播到腾讯微博','width=700,height=680,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,location=yes,resizable=no,status=no');break;case'kaixin':var url='http://www.kaixin001.com/repaste/share.php?rurl='+purl+'&rcontent='+encodeURIComponent(""+title)+'&rtitle='+encodeURIComponent("欣和食与家");window.open(url);break;case'renren':var url='http://share.renren.com/share/buttonshare.do?link='+purl+'&title='+encodeURIComponent(""+title);window.open(url);break;case'douban':var url='http://www.douban.com/recommend/?url='+purl+'&title='+encodeURIComponent(""+title);window.open(url);break;case'qzone':var url='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(""+title)+'&pics='+img;window.open(url);break}}
</script>
</head>
<body>
<a href="#" onclick="sharePlugin('renren','http://www.phpernote.com/images/logo.gif','http://www.phpernote.com')">分享到人人网</a>
<br />
<a href="#" onclick="sharePlugin('tqq','http://www.phpernote.com/images/logo.gif','http://www.phpernote.com')">分享到腾讯微博</a>
<br />
<a href="#" onclick="sharePlugin('sina','http://www.phpernote.com/images/logo.gif','http://www.phpernote.com')">分享到新浪微博</a>
<br />
<a href="#" onclick="sharePlugin('kaixin','http://www.phpernote.com/images/logo.gif','http://www.phpernote.com')">分享到开心网</a>
</body>
</html>

<script>
document.body.onselectstart=document.body.oncontextmenu=function(){return
false;};</script>

近期往往的应用将内容共享到各大社交平台的作用,由此对该意义做了一下小小计算,首假若应用Javascript将内容共享到各大社交平台网址开始展览汇总整理了眨眼间间,小结要点如下,希望能帮到有需求的相爱的人。

复制代码

您或者感兴趣的文章

http://www.bkjia.com/jQuery/763978.htmlwww.bkjia.comtruehttp://www.bkjia.com/jQuery/763978.htmlTechArticle最近频繁的使用将内容分享到各大社交平台的功能,因此对该功能做了一下小小的总结,主要是使用Javascript将内容分享到各大社交平台网站

/**
*JS复制代码
*/
function copyData(text){
var clipBoardContent,clip,trans,str,len,str,copytext,clipid;
clipBoardContent = text;
if(window.clipboardData){
   window.clipboardData.clearData();
   window.clipboardData.setData(“Text”, clipBoardContent);
}
else if(navigator.userAgent.indexOf(“Opera”) != -1){
   window.location = clipBoardContent;
}
else if (window.netscape){
   try{
   
netscape.security.PrivilegeManager.enablePrivilege(“UniversalXPConnect”);
   }catch (e){
   
alert(“您的此时此刻浏览器设置已关门此效用!请按以下步骤开启此意义!n新开一个浏览器,在浏览器地址栏输入’about:config’并回车。n然后找到’signed.applets.codebase_principal_support’项,双击后装置为’true’。n注明:本成效不会危极您Computer或数额的平安!”);
   }
   clip =
Components.classes[‘@mozilla.org/widget/clipboard;1’].createInstance(Components.interfaces.nsIClipboard);
   if (!clip) return;
   trans =
Components.classes[‘@mozilla.org/widget/transferable;1’].createInstance(Components.interfaces.nsITransferable);
   if (!trans) return;
   trans.addDataFlavor(‘text/unicode’);
   str = new Object();
   len = new Object();
   str =
Components.classes[“@mozilla.org/supports-string;1”].createInstance(Components.interfaces.nsISupportsString);
   copytext = clipBoardContent;
   str.data = copytext;
   trans.setTransferData(“text/unicode”,str,copytext.length*2);
   clipid = Components.interfaces.nsIClipboard;
   if (!clip) return false;
   clip.setData(trans,null,clipid.kGlobalClipboard);
}
return true;
}

代码一复制专题地址,传给QQ/MSN上的知音

<title>JS 禁止复制</title>
<body>那是一段测验文字,你能够点击一下右键测验:<br>大家为你提供高格调编制程序源码、JavaScript/CSS特效代码、常用编程软件下载等。</body>

复制文本框内容的代码:

在js中只要要完结复制内容
最轻便易行的大家平素点击按键实行理并答复制,大家都会利用到window.clipboardData.setData(\”Text\”,\’内容了www.bKjia.c0m\’);,上边小编来总括了有滋有味的复制效果代码。

复制代码

<input onclick=”oCopy(this)” value=”要copy的内容!”>

<script> 
function oCopy(obj){ 
obj.select(); 
js=obj.createTextRange(); 
js.execCommand(“Copy”) 

</script>

多少个比较周详的可推断区别浏览器的复制代码(IE/Firefox/NS)

http://www.bkjia.com/AJaxjc/448767.htmlwww.bkjia.comtruehttp://www.bkjia.com/AJaxjc/448767.htmlTechArticle在js中如果要实现复制内容最简单的我们直接点击按钮进行复制,我们都会使用到window.clipboardData.setData(\\"Text\\",\\'内容了www.111cn.net\\');,下面我

复制代码

 代码如下

复制代码

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图