0

由于不再支持@anywhere,我正在寻找一种很好的方法来让人们直接从没有 Twitter 小部件的页面发送推文。

可以创建一个 URL 来填充推文的文本:

https://twitter.com/intent/tweet?text=hello+this+is+a+test+message

有没有办法制作一个输入字段,让填写的文本转换为文本+文本+文本格式。通过提交此填充文本,它将链接到上述 URL 类型。

因此,如果我输入:“我爱你们!” 提交将导致链接到: https ://twitter.com/intent/tweet?text=I+love+you+guys !

4

2 回答 2

1

当然!

<input type="text" name="msg" /><button>Tweet!</button>

<script>
    document.querySelector('button').addEventListener('click', function() {
        var msg = document.querySelector('input[name=msg]').value.replace(/ /g, '+');
        location.href = 'https://twitter.com/tweet.php?text=' + msg;
    });
</script>
于 2013-04-25T09:46:32.070 回答
0

split("match").join("replace") - 这似乎违反直觉,但它设法在大多数现代浏览器中以这种方式工作。

在您的情况下,我认为您可以string =split(" ").join('+').to 以 text+text+text 形式输入字符串

于 2013-04-25T09:45:57.477 回答