views:

31

answers:

2

Hi!

Is it possible to extend the DOM of a new window that I opened, using something like this:

var newWindow = window.open('about:blank', 'testWindow', '');
Element.extend(newWindow);

I thought Element.extend would work.. But I done see any refference to prototype in the DOM.

Any ideas?

Thank you! Morten

A: 

Why you don't want to load prototype again in the new window??? I mean the reference is in cache so, it doesn't matter if you insert it again... is there a reason???

nahum
A: 

It will probably not work for about:blank because of the cross-domain security policy. You can not access the DOM of a new window if that window isn't displaying a page from the same domain.

Secondly, even if the window is same origin, you can not access its DOM as soon as you open it. You need to wait for it to load. The easy way is to have the child window call a function in the parent window when it's done loading (after DOMContentLoad or Window.onload). Or you can repeatedly check if the DOM is available in a setTimeout loop (do not use a while loop because it hangs the browser till the child window is ready). Once the DOM is ready, you can do what you want to do with it.

Chetan Sastry