Closed Thread Icon

Preserved Topic: writing to a window I opened with javascript (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18547" title="Pages that link to Preserved Topic: writing to a window I opened with javascript (Page 1 of 1)" rel="nofollow" >Preserved Topic: writing to a window I opened with javascript <span class="small">(Page 1 of 1)</span>\

 
maninacan
Paranoid (IV) Inmate

From: Seattle, WA, USA
Insane since: Oct 2001

posted posted 09-17-2002 15:38

uh, title is pretty self explanatory. So what I tried was:

mywindow = window.open(blahblahblahblah);
mywindow.write(blahblahblahblah);

*I didn't actually write blahblahblahblah you fools, I just put that there because it's not a part of the script you need to know.

So it opened the window fine, but it said object does not support this property or method when I tried to write to it.

behmer

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-17-2002 15:44

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-17-2002 15:49

And don't forget you'll need to call mywindow.document.close(); afterwards.

maninacan
Paranoid (IV) Inmate

From: Seattle, WA, USA
Insane since: Oct 2001

posted posted 09-17-2002 17:20

uh, wouldn't mywindow.document.close(); close the window?

behmer

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-17-2002 17:24

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-17-2002 19:30

Deprecated? Really?

If you write to a document without closing it, what you write to it won't show up. (This isn't the case when you're writing as the page loads, but if the page has already loaded, then this is the case. Or at least I read that it was the case, perhaps it's changed?)

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-17-2002 19:37

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-17-2002 20:56

It's ok. =)

In any case, I think what maninacan really needs here is an explanation of the difference between the Window object and the Document object.

The Window object (accessed via the "window" or "self" variables) is the top level object. If you view objects and their properties as a tree, the Window object is at the very top, which stems down into many many other objects, like the Array, Date, Math, Object, and Document objects, and a bunch of other variables. Each of these stems down into more objects and variables. And functions, too.

The Window object, in general, represents the window (or frame) that is holding the web page that the script is being executed in. It contains things that are specific to ECMAScript and have nothing to actually do with the document itself: the Math object, for instance, contains mathematical functions. This isn't really related to HTML, but it's something a script might need. Same with the Array object. There are exceptions to this rule: the Location object (window.location) can be modified to change the location of the document. However, in general, the properties of the Window object have little to do with the document.

By the way: The Window object has two variables, "window" and "self", which refer to itself. That's why window.open() is the same as just open(). Both are the same as window.window.window.window.open(). It's a circular reference. All "global" variables are really just children of the Window object.

The Document object (window.document), however, contains things that are specific to the document being displayed in the window or frame. All the DOM (document object model) methods and properties of the entire document are contained within the Document object. The Document object is a huge branch of the tree. Inside it is every piece of data about every node in the entire document, including its style properties and much more. The most common way to get to these nodes is through document.getElementById('id').

The Document object also contains things like the document's location (document.location, which is separate from window.location, though they behave the same in some browsers, even when they shouldn't), the document's style sheets, and more.

So, when you want to change the appearance of the document, you must use the Document object. (document.write is the simplest way during page load.) To change the window (to open a new window or close the current one or other window-related activities), you use the Window object.

the open() method of the Window object (window.open()) returns a reference to the Window object of the new window that's been opened. In your first post, this would be mywindow. To access the document of that window, you can use mywindow.document.

Anyway, I think i've covered most of the important points, so I'll be off now.

« BackwardsOnwards »

Show Forum Drop Down Menu