How to create a new window object without iframe?

How can I create a new object Window, myWindowwhich is independent of Window(so the change, for example, myWindow.Array.prototypedoes not affect window.Array.prototype), without creating <iframe>?

I am currently doing this as follows

function newWindow(){
    var myFrame = document.createElement('iframe'), myWindow = undefined;
    myFrame.style.display = 'none';
    myFrame.src = 'javascript:undefined;';
    document.body.appendChild(myFrame);
    myWindow = myFrame.contentWindow;
    document.body.removeChild(myFrame);
    return myWindow;
}

Ultimately, I would like to make my own copies of the main types of objects and prototype them.

+5
source share
2 answers

Umm ... you can't do this. Well ... you can call window.open, but it will open a new window. And ... why do you need this? Sounds like you're wrong.

+1
source

, , , .

function augmentArray(a) {
  a.purgeAll = function() {a.length = 0;};
}

var myList = [1, 2, 3];
augmentArray(myList);
myList.purgeAll();
0

All Articles