我让生成器和共享链接都工作了,但是我不能让它们填充最后的'sillyname‘变量。又名当你点击分享时,它有一个通用的消息,但我试图让它在推文或facebook分享文本中动态输入名称。
这方面的任何帮助都将是非常棒的。
这里是你深入挖掘的链接。http://codepen.io/drewlandon/pen/VLvpjq
我在twitter/facebook的分享函数中有如下内容:
var twitterWindow = window.open('https://twitter.com/intent/tweet?url=http://sweetleafmarijuana.com/&text=My Sweet and Fierce Name... &via=TheSweetestLeaf &hashtags=SweetFierceName', 'twitter-popup', 'height=350,width=600'); if(twitterWindow.focus) { twitterWindow.focus(); }
return false; } var facebookShare = document.querySelector('[data-js="facebook-share"]');然而,我发现了这一点,我觉得它应该是这样的:
function twitterShare(){
var shareText='My funny pseudonym is '+accents_to_regulars(outputName)+', according to @...'所以我想我需要这样的东西(但在那里有麻烦)
var twitterMessage = "My #SWEETFIERCENAME is " + hungryName + ", according to @thesweetestleaf's #SweetFierceName Name Generator";
var facebookMessage = "My name is " + hungryName + "";发布于 2015-05-06 06:25:46
您需要转义URL的文本。
它在这里工作:http://codepen.io/anon/pen/Kpdvqa
twitterShare.onclick = function(e) {
e.preventDefault();
var twitterWindow = window.open('https://twitter.com/intent/tweet?url=http://sweetleafmarijuana.com/&text='+encodeURIComponent(getSillyName())+'&via=TheSweetestLeaf &hashtags=SweetFierceName', 'twitter-popup', 'height=350,width=600');
if(twitterWindow.focus) { twitterWindow.focus(); }
return false;
}#字符在URL中具有特殊含义。
至于Facebook的消息,现在已经没有办法预先填充了:http://www.quora.com/With-Facebooks-share-link-is-there-a-way-to-prefill-the-text-to-be-posted
您必须仔细查看FB Feed Dialog才能看到其他选项,比如可能会改为更新caption属性。
https://stackoverflow.com/questions/30062728
复制相似问题