IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New comments, and thanks
I don't think Mozilla will let you use the opener.FormName method of referencing a form, it seems to be an IE specific thing. I think you will have to after it by going from opener to document to forms[].

You mean make a reference object first rather than one big dotted path thingy? I'll give it a try. (Damn, I wish DOM was relational.)

As for the second question, functions are just another object in Javascript. I child form can call a function in it's parent form by doing opener.functionname().

I tried that already. It did not work in either browser. Maybe I'll try it again if the above does not work.

Thanks.



________________
oop.ismad.com
New Re: comments, and thanks
You mean make a reference object first rather than one big dotted path thingy? I'll give it a try. (Damn, I wish DOM was relational.)

No, what I meant is that using the name of the form in the code the way you did seems to be an IE only thing. I was thinking something like opener.document.forms[0].select1[1].selected would work, but opener.getElementByID is probably better.

In any case here are two simple examples I hacked up to test it making calls across windows.

Jay
New HTMLTest
\n<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[link|http://www.w3.org/TR/html4/loose.dtd|http://www.w3.org/TR/html4/loose.dtd]">\n<html><head>\n<script LANGUAGE="JavaScript">\nvar WinRef\nfunction TryIt(){alert("Hello From Parent");}\nfunction TrySel(){window.document.forms[0].Sel1[2].selected = 1;}\nfunction TrySel1(){WinRef.document.forms[0].Sel1[2].selected = 1;}\nfunction OpenSub(){WinRef = window.open("HTMLTest1.html","bob","height=150,width=250");}\nfunction TryCall(){WinRef.SubAlert();}\n</script>\n</head>\n<body>\n<form method="POST" action="." name="Form1">\n<select name="Sel1" >\n\t<option selected="selected" value="Zero">Zero</option>\n\t<option value="One">One</option>\n\t<option value="Two">Two</option>\n\t<option value="Three">Three</option>\n</select>\n</form>\n<input type="button" name="Button1" value="Open" onClick="OpenSub()">\n<input type="button" name="Button2" value="TryCall" onClick="TryCall()">\n<input type="button" name="Button0" value="Update My Select" onClick="TrySel()">\n<input type="button" name="Button3" value="Update Sub Select" onClick="TrySel1()">\n</body></html>\n
New HTMLTest1
\n<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[link|http://www.w3.org/TR/html4/loose.dtd|http://www.w3.org/TR/html4/loose.dtd]">\n<html><head>\n<script LANGUAGE="JavaScript">\nfunction TryIt1(){opener.TryIt();}\nfunction TrySel(){opener.document.forms[0].Sel1[2].selected = 1;}\nfunction SubAlert(){alert("Hello From Test");}\n</SCRIPT>\n</head>\n<body>\n<form method="POST" action="." name="Form1">\n<select name="Sel1">\n\t<option selected="selected" value="Zero">Zero</option>\n\t<option value="One">One</option>\n\t<option value="Two">Two</option>\n\t<option value="Three">Three</option>\n</select>\n</form>\n<input type="button" name="Button1" value="TryIt" onClick="TryIt1()">\n<input type="button" name="Button0" value="Update Parent Select" onClick="TrySel()">\n</body></html>\n
New Thanks, works with "document" in there.
It works in Mozilla when I put "document" in the expression. I am still fuzzy on the relationship between Window and Document in DOM. It looks one-to-one to me. If so, it is bad normalization it would seem. Is it possible to overlap documents, such as in layers?
________________
oop.ismad.com
New I don't think so
I don't think a window can ever have multiple documents, as both layers and frames are handled as parts of a document. It is possible it have a window with no document, but it's not very common.

It's probably that way because the guys that did the early Netscapes had some object oriented experience. Seperating the Window object and the Document object despite their near perfect unity is very OO.

Jay
New Windows can have *many* documents
The current document, the previous document, the one previous to that...

That nobody ever chose to expose this doesn't mean that it was a bad initial idea to have made it possible to choose to do so.

Incidentally the frames array belongs to a Window, and not the Document. (Or at least used to.)

Cheers,
Ben
To deny the indirect purchaser, who in this case is the ultimate purchaser, the right to seek relief from unlawful conduct, would essentially remove the word consumer from the Consumer Protection Act
- [link|http://www.techworld.com/opsys/news/index.cfm?NewsID=1246&Page=1&pagePos=20|Nebraska Supreme Court]
New Another reason for it
You can pop up a new empty window with javascript, and then dynamically write contents into it. Until you've written something into it, the window has no document. There are probably also some theoretical guidelines on closing the window for writing before the document exists in the DOM, but considering how loosely browsers interpret invalid code I wouldn't bet on those guidelines ever having been followed.
===

Implicitly condoning stupidity since 2001.
New got me thinking about a relational version of DOM
________________
oop.ismad.com
     JavaScript cross-window questions - (tablizer) - (12)
         Answers - (JayMehaffey) - (9)
             comments, and thanks - (tablizer) - (8)
                 Re: comments, and thanks - (JayMehaffey) - (7)
                     HTMLTest - (JayMehaffey)
                     HTMLTest1 - (JayMehaffey) - (5)
                         Thanks, works with "document" in there. - (tablizer) - (4)
                             I don't think so - (JayMehaffey) - (3)
                                 Windows can have *many* documents - (ben_tilly) - (2)
                                     Another reason for it - (drewk) - (1)
                                         got me thinking about a relational version of DOM -NT - (tablizer)
         Something more along the lines of - (ChrisR) - (1)
             opener.getElementById("things").selectedIndex, or - (FuManChu)

About Three Miles long and right up the wazoo.
43 ms