DOM on new open window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NKTA
    New Member
    • Jan 2010
    • 26

    DOM on new open window

    Hello.


    I have a question regarding method window.open(... ) or open(...).

    If i use this method to open a new window, is it possible to use DOM to append objects to that same window, or is it restricted.

    I have been searching for foruns and web in general, there seems not having a straight answer.

    Giving an example, with an event Listener i detect the keypress "Enter", which in then it triggers the opening of a new window with the intended page, in this case the same page, but i wanted to change some parts of it by adding objects to it (append them).
    Code:
    newWindow = window.open('test.html','newWindow','width=640,height=480,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
    
    var tmp = newWindow.document;
       	
    var divAll = containerDiv = document.createElement('DIV');
        divAll.id = "area-"+Number;
        divAll.style.height = 45+"px";
        divAll.style.width = 45+"px";
        divAll.overflow = "scroll";
        divAll.overflow.x = "hidden";
        divAll.overflow.y = "auto";
    var containerDiv = document.createElement('DIV');
        containerDiv.id = "div_"+Number;
        containerDiv.name = "original";
        containerDiv.style.height = 45+"px";
        containerDiv.style.width = 45+"px";
        containerDiv.style.position = "absolute";
    var project = document.createElement('IMG');
        project.id = "projecto_"+number;
        project.numero = number;
        project.style.height = 45+"px";
        project.style.width = 45+"px";
        project.style.position = "absolute";
        project.setAttribute('src', "7656756.jpg");
    
        containerDiv.appendChild(project);
        divAll.appendChild(containerDiv);
        tmp.getElementById('myArea').appendChild(divAll);
    The following error appears: This interface is not supported ...

    Is it possible to use a page to call itself with the method window.open(... ) and then use DOM to change its content ? Or is it a restriction or problem with same Origin Policy ?

    Thank You
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    It's possible that the new window has not fully loaded. You could set tmp in the parent window from the child window when it (the child window) has fully loaded (onload event).

    Comment

    Working...