Olaf wrote:
[color=blue]
> I have a frameset page witch contains the myFuc() function. The
> function is accessed from a page in one of the frames in the frameset.
> An example is shown below.
>
> <input onclick="javascript
:alert('document.forms(0)='+doc ument.forms(0));
> parent.myFunc(document.forms(0));" type="button" value="Open"
> name="Button" ID="Button">
>
> The strange part is that the debug alert says that the
> document.forms(0) is an object så all seem to be well. But directly
> afterwords when parent.myFunc(document.forms(0)) is to execute, the
> page halts with the "Object doesn't support this property or method"
> error message.
>
> How can it be allright first and then not?
>
> /Olaf[/color]
Are you sure it isn't parent that doesn't support myFunc().
Try alert(parent.myFunc);
Also, the proper notation for collections in Javascript is using square
brackets. Curved brackets (braces) may work in Internet Explorer, but it will
break in any other browser. So use document.forms[0] rather then
document.forms(0)
And you don't need the "javascript
:" label in events unless you've defined
your first script block as <script language="VBScript">.
And you don't need to refer to the form using the complete DOM hierarchy if
it's the same form the current element resides in, because each form element
has a property "form" which refers to it's parent form.
So putting it all together...
<input onclick="alert(parent.myFunc); /* parent.myFunc(this.form); */"
type="button" value="Open" name="Button" ID="Button">
--
| Grant Wagner <gwagner@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html