在 jQuery 移动应用程序中更改 AddThis 共享 URL

Changing the AddThis shared URL in a jQuery mobile application

本文关键字:AddThis 共享 URL jQuery 移动 应用程序      更新时间:2023-09-26

我在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 });