更改共享按钮的内容
问题描述:
因此,我使用这个共享按钮插件的Twitter和面子书。 但是,我不明白我应该改变什么来获得我的网址和我的标题时按下按钮。 plz帮助。更改共享按钮的内容
HTML:
<a onclick="Share.facebook('URL','TITLE','IMG_PATH','DESC')"> {sharing is sexy}</a>
<a onclick="Share.twitter('URL','TITLE')"> {sharing is sexy}</a>
JS:
Share = {
facebook: function(purl, ptitle, pimg, text) {
url = 'http://www.facebook.com/sharer.php?s=100';
url += '&p[title]=' + encodeURIComponent(ptitle);
url += '&p[summary]=' + encodeURIComponent(text);
url += '&p[url]=' + encodeURIComponent(purl);
url += '&p[images][0]=' + encodeURIComponent(pimg);
Share.popup(url);
},
twitter: function(purl, ptitle) {
url = 'http://twitter.com/share?';
url += 'text=' + encodeURIComponent(ptitle);
url += '&url=' + encodeURIComponent(purl);
url += '&counturl=' + encodeURIComponent(purl);
Share.popup(url);
},
popup: function(url) {
window.open(url,'','toolbar=0,status=0,width=626, height=436');
}
};
答
window.location.href
会给你的页面的URL,并document.getElementsByTagName("title")
会给你页面的标题元素。
是否回答你的问题,或者是你寻求建立在准确的时间按下按钮时,这些价值?
我找到了答案我自己,这是很明显的,你只是在标签更改“标题”永远你想要的东西。我的问题是,我在标签内使用了一个''',所以它出现了故障:P谢谢! – 2013-03-21 20:55:52