我目前有一個網站,包括我正在創建的社交網絡小工具上的Google分享按鈕(以及Facebook和Twitter)。我想要做的是能夠在textarea字段中輸入一些文本,並在按下「發送」按鈕時,文本被分享到Google+用戶的牆上(我已經有Facebook和Twitter的帖子可以工作)。現在我知道Google +的共享按鈕有一個名爲「data-prefilltext」的字段,這是我試圖用textarea中的消息設置的字段。當我按下「發送」按鈕時,我可以看到「數據預填文本」字段值的變化,但在彈出窗口中,我看不到文本更改。下面是代碼:谷歌分享按鈕動態設置數據預充文本
HTML:
<div id="googleplus-selector" title="App is what's new! Share it with your circles in Google+"
class="social-networking-icons g-interactivepost"
data-contenturl="http://plus.google.com/pages/"
data-contentdeeplinkid="/pages"
data-clientid="clientid.apps.googleusercontent.com"
data-scope="https://www.googleapis.com/auth/youtube.readonly"
data-cookiepolicy="single_host_origin"
data-prefilltext="Share App with your circle of friends now!"
data-calltoactionlabel="TRY_IT"
data-calltoactionurl="http://plus.google.com/pages/"
data-calltoactiondeeplinkid="/pages/create"
data-href="http://mysiteurl">
<div class="widget-mask"></div>
</div>
的Javascript/jQuery的:
var textElement = $('#social-message-text');
var text = textElement.val();
$('#google-plus-share-button').attr('data-prefilltext', text);
就像我說的,我可以看到在檢查屬性值變化螢火蟲或谷歌的開發者控制檯中的元素但是,當打開Google共享彈出窗口時,文本中的更改不會反映出來。
任何幫助將不勝感激,因爲我現在有點難住。提前感謝大家。
找到任何解決方案? – movsky