我終於解決這個問題的方式就像這樣。
在HTML文件中,我定義兩個div此起彼伏:
<div id="share_fixed">
<a class="twitter-share-button" href="http://twitter.com/share" data-url=" " data-size="large" data-show-count="false" data-text=" ">
</a>
</div>
<div id="share">
</div>
ID爲DIV =「share_fixed」中將包含一條推按鈕,這將是靜態的(僅在頁面加載時呈現)。 id =「share」的其他div將包含Tweet按鈕,每次發生某個事件時都會重新渲染(更新)。
在兩個分隔上同一位置的CSS我的位置和覆蓋其上固定一個頂部變更中的一個:
#share {
position: absolute;
bottom: 12px;
left: 15px;
z-index: 1;
}
#share_fixed {
position: absolute;
bottom: 12px;
left: 15px;
z-index: 0;
}
這實際上將迫使固定的「虛擬」分享Tweet按鈕始終被定位低於重新加載時發生改變和閃爍的那個。每當頂部的按鈕改變並「閃爍」下面的按鈕時,它將保持不變,因爲它完全相同,所以看起來沒有任何變化。
在Javascript文件中,我添加了例如是這樣的:
var tweetBtn = $(document.createElement('a')).addClass("twitter-share-button")
.attr('href', 'http://twitter.com/share')
.attr('data-url', ' ')
.attr('data-size', 'large')
.attr('data-show-count', 'false')
.attr('data-text', "Some new tweet text");
$("#share iframe").remove();
$("#share").append(tweetBtn);
twttr.widgets.load();
我想有更多的方式來解決這個問題,但是這對我的作品在Chrome,還沒有嘗試過在其他瀏覽器。
首先加載twitter按鈕,然後'onLoad',隱藏/擺脫第一個。 – Feathercrown
當你說twitter按鈕時,你是什麼意思? 由於twitter按鈕的更新方式是從DOM中刪除呈現的'