我在尝试动态更改要与 jQuery Mobile 应用程序中的 AddThis 共享的 URL 时遇到问题。
下面代码片段中的response.url是Bitly提供的URL,例如“http://shorturl.com/hu7Hnm”,但是我无法使用此代码更改URL。我在我们的桌面网站上做了同样的事情,效果很好,但它在我们的移动网站(由 jQuery Mobile 提供支持)上不起作用。
Twitter/Facebook/电子邮件弹出窗口仍然出现,但它们显示了被下面的更新代码更改之前的 URL。所以看起来没有任何影响。
// update the AddThis share url to the shortened URL
addthis.update('share', 'url', response.url);
addthis.url = response.url;
addthis.toolbox('.social_icons');
social_icons 选择器的目标是下面的这个,它包含 AddThis 图标。
<ul class="social_icons inline_list">
这是我在页面加载上进行共享设置的示例:
var addthis_share = {
url: "http://www.wrestlemaniamainevent.com/shared/huih897897jkhjkh98907908nn",
title: "Check out the Main Events at www.wrestlemaniamainevent.com"
}
最佳答案
我找到了解决这个问题的方法。它需要在声明的开头指定 window
对象。我相信这是使用 jQM 的一个怪癖。
window.addthis.toolbox('.social_icons', {}, {'url': response.url });
关于javascript - 更改 jQuery 移动应用程序中的 AddThis 共享 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27023280/