1

我使用 Jquery-Mobile & Phonegap 开发移动应用程序。我想使用 twitter 分享脚本分享动态数据:

当我在外部页面中使用此代码时“不使用 jquery-mobile 或任何其他脚本,它工作正常。

html:

<a href="http://twitter.com/share" 
data-url="http://your.url.com/yourdynamicpage" 
class="twitter-share-button" 
data-text="What should I share?" 
data-count="horizontal">Tweet</a>

但是,当我将其添加到 javascript 文件中以动态添加信息“Data-text”和“Data-Url”时,twitter 会在其中没有这些数据的情况下打开。

html:

Javascript:

$('#TwitterShare').append('<a href="http://twitter.com/share" rel="external" 
data-url="http://your.url.com/yourdynamicpage" 
class="twitter-share-button" 
data-text="Dynamic Data will be inserted here" 
data-count="horizontal">Tweet</a>');

当我静态添加行时,发送的链接是:

https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Flocalhost%3A3025%2FShareTrial.html&source=tweetbutton&text=What%20should%20I%20share%3F&url=http%3A%2F%2Fyour.url.com%2Fyourdynamicpage

但是当它被动态添加时,链接上不会发送任何数据:

https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Flocalhost%3A3025%2FViewPost.html&url=http%3A%2F%2Flocalhost%3A3025%2FViewPost.html

我想知道为什么会发生这种情况以及我该如何解决?

谢谢。

4

0 回答 0