【发布时间】:2011-09-13 06:47:24
【问题描述】:
我正在尝试创建一个带有弹出窗口的自定义推文按钮,这部分有效。但是,我无法让它在文本区域中发布主题标签。
推文内容
url=http://www.mywebsite.com&text=mytweetcontent&via=mytwitterusername
在 &text= 中,我尝试使用 mytweetcontent+#myhashtag 以及尝试使用 URL 编码 %23(对应于 #);但是,我仍然无法显示主题标签。关于我能做什么的任何想法?我希望有一个自定义图像,这就是为什么我不使用专有的 twitter jscript 按钮。非常感谢您的帮助!
完整代码供参考:
<a href="javascript:(function(){window.twttr=window.twttr||{};var D=550,A=450,C=screen.height,B=screen.width,H=Math.round((B/2)-(D/2)),G=0,F=document,E;if(C>A){G=Math.round((C/2)-(A/2))}window.twttr.shareWin=window.open('http://twitter.com/share?url=http://www.mywebsite.com&text=%23+mytweetcontent&via=mytwitterusername','','left='+H+',top='+G+',width='+D+',height='+A+',personalbar=0,toolbar=0,scrollbars=1,resizable=1');E=F.createElement('script');E.src='http://platform.twitter.com/widgets.js';F.getElementsByTagName('head')[0].appendChild(E)}());"><img src="twitter-logo.png" border="0"></a>
编辑*回复评论
感谢您的建议!我没有尝试使用标签,只是正常的,但是将 & 更改为 ?删除内容区域,代码如下。顶行是推文框中的结果,下面是相应的 url。
我的内容http://t.co/nKb4nWC 通过@myusername
http://twitter.com/intent/tweet?text=mycontent&url=http%3A%2F%2Fwww.mywebsite.com&via=myusername
http://t.co/YzrDfzX 通过@myusername
http://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.mywebsite.com%3Ftext%3Dmycontent&via=myusername
【问题讨论】:
-
我认为(我还没有时间对此进行测试)问题在于您在“.com”之后使用
&而不是?。浏览器不喜欢这样,它的格式不正确。
标签: javascript jquery ruby-on-rails twitter