小弟初学者,做个JS分享功能,比如人人的http://share.renren.com/share/buttonshare.do?link={url}&title={title},title和url我都获取到了,可知不知道怎么用js把这两个参数传到href里面,求助,在线等

解决方案 »

  1.   

    var title="xxx";
    var url="xxx";
    var shareLikn="http://share.renren.com/share/buttonshare.do?link={"+url+"}&title={"+title+"}";
      

  2.   

    人人网的分享的例子function renren() {
        content = $(".Content").html();
        RenRenContent = encodeURI(content);
        var attt = $("#img").attr("src");    window.location.href = "javascript:void((function(s,d,e){ var f='http://share.renren.com/share/buttonshare?link=',u=location.href,l='" + content + "',p=['" + attt + "','&title=', e(l)].join('');function a(){if(!window.open([f,p].join(''),'xnshare',['toolbar=0,status=0,resizable=1,width=626,height=436,left=',(s.width-626)/2,',top=',(s.height-436)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();})(screen,document,encodeURIComponent));";
    } <img class="img" title="分享到人人网" onclick="renren()"
      alt="分享到人人网" src="Images/CreatePic/renren.png" />