[英]Click tweet button after changing data-text
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.