I am trying to open a new window with values received from textfield with id "name";
<form name="myForm">
<input type="text" id="name">
</form>
<button onclick="openWindow();">Open</button>
And this is the javascript:
function openWindow() {
newWindow = window.open("", null, "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");
newWindow.document.write("<h1>"+document.myForm.name.value+"</h1>");
}
It does it ok, but why does it empty the form values?
And how can i center this new window? Maybe height=window.height()/2 ?
myFormas the actual element. Or at all.