Juan Juan - 1 month ago 8
Javascript Question

Insert text in a new window with javascript

Sorry for my English, is very bad. I want to create a new window with the twitter's intent page ,and then insert text in the textarea. This is my code, it doesn't work.

var myWindow = window.open("https://twitter.com/intent/tweet");

myWindow.onload = function() {
myWindow.document.getElementById("status").innerHTML="Hey you!!";
}

Answer

You can't use JavaScript to modify pages on other people's websites. It would be a huge security problem if it were possible.

Read Twitter's developer documentation. It shows you how to set default text for an intent:

<a href="https://twitter.com/intent/tweet?text=Hey+you!!">…</a>