簡體   English   中英

更改數據文本后單擊tweet按鈕

[英]Click tweet button after changing data-text

我正在嘗試使用此處的教程更改Twitter分享按鈕上的數據文本: DEMO

但是,有什么方法可以在更改數據文本后自動單擊“新” tweet按鈕嗎? 因為必須手動單擊才能顯示共享窗口

Tweet按鈕位於另一個域的iframe中,因此您將無法訪問它。 我也找不到有關如何以編程方式打開窗口的任何文檔,所以這是我的hacky解決方案:只需向https://twitter.com/intent/tweet打開一個彈出窗口,然后在查詢字符串中傳遞必要的參數即可。 無需鳴叫按鈕。

<label for="tweetText">Tweet this:</label>            
<input type="text" name="tweetText" id="tweetText" />
<input type="button" value="Tweet" id="tweetSubmit" />

function popitup(url) {
  newwindow=window.open(url,'name','height=850,width=730');
  if (window.focus) {newwindow.focus()}
  return false;
}

$('#tweetSubmit').on('click', function() {
  var text = $("#tweetText").val();
  popitup(
    "https://twitter.com/intent/tweet?text=" + text + 
    "&url=" + 'http://test.com'
  )
});

這應該按需要工作。 演示

來自強大的PPK的彈出功能: http : //www.quirksmode.org/js/popup.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM