I am trying to pass data from a parent window to a child window. But there are several problems. The code snippet is following:

Parent Window:
var v = document.createElement("input");
v.setAttribute('id', 'test');
v.setAttribute('value', 'TEST');

function openNewWindow() {
var w = window.open("childwindow");

Child Window:
var v = window.opener.document.getElementById("test");

The first problem is that the alert(v) in Child window returns a null. It seems like v is not delivered from parent window to the child window. Also, the parent window is reloaded when I click the button which triggers openNewWindow function in parent window.

I have no idea of that problems. Any suggestion is very welcomed.