javascript - 更改 jQuery 移动应用程序中的 AddThis 共享 URL

标签 javascript jquery facebook jquery-mobile addthis

我在尝试动态更改要与 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/

相关文章:

java - 部署安卓应用。 gradle 缺少 'installReleaseDebug' 任务

javascript - 我可以将 NPX 与 yarn 一起使用吗?

javascript - 悬停时触发 div

javascript - 使用右侧选择器定位 div

javascript - 如何在一行中滑动 div?

facebook - 验证多个域的应用程序

ios - 在 Facebook Developers App 上添加多个 iOS 包 ID 的通配符?

javascript - 随着屏幕变大,Div 漂浮到一边?

javascript - 从命令按钮单击更改丰富的面孔扩展数据表高度

javascript - 自定义 Highchart 工具提示