Why trying to send data between windows if you can have direct access to the content/DOM of the parent window? This will give you advantages when the content of your textarea is/can be changed. The "child page" will keep a reference to the page that opened it!
parent.html
<textarea id="mytext" name="textcode"></textarea>
<button type="submit" onclick="myFunction()">Open in New window</button>
<script>
function myFunction() {
//open popup/window on the same domain
window.open('newwindow.html','newwindow','width=350,height=350');
}
</script>
When the new window opens you can have access to it's parents DOM only if they are on the same domain.
In your newwindow.html
you can access your textarea (or any other DOM element) with window.opener
:
window.opener.document.getElementById("mytext").value
Like I said, this only works when your parent and child windows are on the same domain. You will run into "same-origin policy errors" when parent and child aren't in the same domain.
However! you can use Window.postMessage
to safely pass data between windows that aren't on the same domain. This isn't supported that well in all browsers.
otherWindow.postMessage(message, targetOrigin, [transfer]);
You can find an example and additional information (like browser support etc) on the dev pages of mozilla here