Explanation of window.open(fo,ob,ar).document 
Author Message
 Explanation of window.open(fo,ob,ar).document

Environment:
Jscript in IE 6 (on Windows XP).

I'm using the following chunk of code to create a brand new IE window
and then write to it; I obtained it from a kind WSH NG poster.

function makeNewPage(strData)
{
oNewDoc =
window.open("about:blank","_blank","status=no,toolbar=no,menubar=no,lo
cation=no").document;
oNewDoc.writeln(strData);
oNewDoc.close();

Quote:
}

Unfortunately as I go back and look at it, I am puzzled by what is
going on with the ".document".  I understand "window.open" without any
trouble, but the .document is giving me fits.

My GUESS is that since every time I do this I want to call a brand new
window and then ONLY wish to write to it, that this line was passed to
me as a method of immediately "drilling down" through the IE DOM to
get to the top-level component I would be dealing with - in other
words, I could have done something like

x = window.open(yadda,yadda,yadda);
y = x.document;
y.writeln(strData);

but I haven't been able to make that work either.

Could someone explain this to me?  Also, is this somehow related to
"prototypes" in Jscript (which appear to be at least structurally
similar)?



Fri, 09 Jul 2004 06:16:42 GMT  
 Explanation of window.open(fo,ob,ar).document
the window.open method returns an object reference to the new window.
it's functionally equivalent to doing this

var newwin = window.open('blah', 'blah', 'blah');
newwin.moveTo(0,0);
newwin.doument.write('hey, I'm a new window');

so you're just asking for an object reference to the .document property
of the new window, rather than the window itself. the engine may be
tripping over its own feet though...?

when you say 'i can't get it to work' what happens? error messages?
nothing at all? incorrect output? what?

prototypes in JScript are just another aspect/facet of the 'Object'
type. you may find it illuminating to read the O'Reilly Javascript
manual's section on Objects and object oriented javascript.

Atrax - MVP [Microsoft Most Valued Professional]

http://www.infinitemonkeys.ws/

Host with me for $100 a year!
http://www.atrax.ws/hosting/

please do not reply directly to this email address

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Fri, 09 Jul 2004 08:57:17 GMT  
 Explanation of window.open(fo,ob,ar).document
OOPS -

I've always considered that"this doesn't work" statement with no
explanation to be a cardinal newsgroup sin, too...

The situation was an issue I had with using a script stuck in a WSC
(which I resolved). YOu answered the real question I had, though,
which was whether I was simply drilling the object reference down into
the new window...

Thanks


Quote:
> the window.open method returns an object reference to the new
window.
> it's functionally equivalent to doing this

> var newwin = window.open('blah', 'blah', 'blah');
> newwin.moveTo(0,0);
> newwin.doument.write('hey, I'm a new window');

> so you're just asking for an object reference to the .document
property
> of the new window, rather than the window itself. the engine may be
> tripping over its own feet though...?

SNIP)


Fri, 09 Jul 2004 18:15:01 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Opening Word/Excel Documents in New Window

2. window.open only opens 1 window

3. how do I open the current window again without opening a new window

4. Problem with window opened with window.open method in IE

5. Closing a window that was opened with the window.open method

6. document.write opens new document after setTimeout/setInterval???

7. open document, without open/close application

8. Utopia.gsf missing from ghostscript-fonts-other-3.12.tar.gz

9. Using Window.Open to open HTML page

10. Looking fo a Japanese-to-postcript tool

11. Pageview fo PC's?

 

 
Powered by phpBB® Forum Software