Pur*_*key 3 javascript facebook addthis facebook-like
我在我的网站上有这些AddThis按钮,我的网站使用JS通过图片库获取用户,当更改图像时,URL更新了片段元素中的图像标题,我遇到的问题是这没有被反映出来在AddThis链接中.我试图从AddThis论坛得到一些答案,但是指出了api文档和addthis.toolbox()函数,但它似乎并不适合我,所以我想我会运行它过去这里的专家.
这是我在基本页面上的AddThis代码.
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
<a class="addthis_button_preferred_1 add_this_but"></a>
<a class="addthis_button_preferred_2 add_this_but"></a>
<a class="addthis_button_preferred_3 add_this_but"></a>
<a class="addthis_button_preferred_4 add_this_but"></a>
<a class="addthis_button_compact add_this_but"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_clickback":false};</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e77111e2de880eb"></script>
<!-- AddThis Button END -->
Run Code Online (Sandbox Code Playgroud)
在我的JS脚本中,当用户更改图像时,我已将其添加到该函数中.
addthis.toolbox(".addthis_toolbox");
Run Code Online (Sandbox Code Playgroud)
我也试过这个
addthis.toolbox();
Run Code Online (Sandbox Code Playgroud)
运行代码时,我没有JS错误,但我没有看到AddThis按钮的任何更新.
你可以在这里看到问题.
http://www.martynazoltaszek.com/artpages?nid=30#Rendezvouz
此链接将在名为"Rendezvouz"的特定图像上打开网站,但是nid = 30实际上是一个名为"Walking by"的不同图像.问题由AddThis(Facebook)显示将始终链接到Walking by"图像. AddThis Gmail似乎没问题,但我不认为这是API的一个因素,因为它可以使用或不使用上述函数调用.
提前致谢.
PS之所以使用?NID GET变量和一个片段是由于PHP页面加载和JS浏览(不含页refersh),但这也留下了一个非JS浏览器支持.
Dam*_*orn 12
我在使用hashbangs为javascript驱动的网站时遇到了类似的问题.使用此代码是因为当内容加载异步时,共享按钮不会重新呈现.你应该能够采取一些适合你的情况.也许只是addthis.update()
代码
首先,我将addThis的脚本更改为异步
http://s7.addthis.com/js/250/addthis_widget.js#async=1
Run Code Online (Sandbox Code Playgroud)
加载DOM后,监听hashchanges,这是我们更新addthis共享详细信息的地方.
您可能需要额外的插件才能使用此位来使用旧版浏览器,请考虑jQuery hashchange事件 - v1.3 - 7/21/2010 - http://benalman.com/projects/jquery-hashchange-plugin/
现在它全部用于哈希转换,下一步是改变addThis.
$(function(){
$(window).hashchange(function(){
if($('body').hasClass('addThis')){
addthis.ost = 0;
addthis.update('share', 'url', window.location.href); // new url
addthis.update('share', 'title', window.document.title); // new title.
addthis.ready(); // this will re-render the buttons.
}
else {
addthis.init();
$('body').addClass('addThis');
}
});
addthis.init() //As we've changed the addthis to async, you will have to call addthis.init() once the DOM has loaded.
});
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
归档时间: |
|
查看次数: |
5596 次 |
最近记录: |