How to get a dom element in a new window?

javascript, window

Solution

Alternatively, this is a solution:

var novoForm = window.open("somform.html", "wFormx", "width=800,height=600,location=no,menubar=no,status=no,titilebar=no,resizable=no,");
var teste = function(){
    var mon = novoForm.document.getElementById("monitor");
    if(typeof(mon)!="undefined"){
        //novoForm.alert("Achei!");
        var h = novoForm.innerHeight;
        var strh = String(h - 40 - 30)+'px';
        novoForm.document.getElementById("pagina").style.height = strh;
        novoForm.document.getElementById("monitor").innerHTML = '<p class="legenda">&copy; NetArts | gustavopi</p>';
        clearInterval(id);
    }
}
var id = setInterval(teste, 100);

This will do the job. Not a "pretty" solution to me, but it works!

Problem

A simple task in JavaScript is to open a new window and writing inside. But I need to write in a dom element, a div with an ID. ``` var novoForm = window.open("somform.html", "wFormx", "width=800,height=600,location=no,menubar=no,status=no,titilebar=no,resizable=no,"); ``` Than I try something... ``` var w = novoForm.innerWidth; var h = novoForm.innerHeight; novoForm.document.getElementById("monitor").innerHTML = 'Janela: '+w+' x '+h; ``` I did it to see if the object "novoForm" is valid. But nothing is written in "monitor" div. I also try using onload event with no success. I'm wondering if it's some security restriction or am I missing something...

Original source