473,395 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

strange "Object doesn't support this property or method" problem

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
Jul 23 '05 #1
2 8896
Olaf wrote:
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


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 <gw*****@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
Jul 23 '05 #2
Olaf wrote:
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)); [1]^^^^^^^^^^^ [2]^^^^^^^^^^^^^^^^

[1] Remove that, see the FAQ: <http://jibbering.com/faq/>

[2] document.forms as of the still proprietary, yet widespread, DOM
Level 0 (IE/NN 3+) is a collection, a special object, not a method
(it is now defined as Document.forms HTMLCollection object in the
W3C DOM as well, however `document' is apparently still
proprietary). Use the square bracked property accessor of
ECMAScript, in called the "index operator" in J(ava)Script:

document.forms[0]

BTW: Has it ever occurred to you that client-side scripting
may be disabled and thus the button will do nothing then?
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?


All I can say for sure is that strange syntax often causes strange
behaviour. In your case, document.forms(0) is first used as substring
in a concatenation operation, which would require its value to be
converted to a string prior, using the toString() method on it
internally. However, using the same term as argument for your
function causes it to be evaluated as an object reference. A proper
DOM and script engine would have yield an error like "document.forms
is not a method" in both cases as the call operator (the parantheses)
was used for a non-function property. However, the IE DOM is known
to allow this ambiguity for its host objects: elements of some,
possibly all, collections can be accessed both via the call and the
index operator, the collections being apparently both function and
non-function properties. And the error message you have reported
suggests that you are testing with IE (which you should have reported, too).
PointedEars
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: KathyB | last post by:
I have the following script in an html page: function goToPosition() { varGoTo = document.write(document.cookie("Position")); document.scrollTo(0, varGoTo); } </head> <body...
2
by: SmittyBroham | last post by:
Hello, I have a function that loops through 2 select lists and records the values of any hi-lighted options a user would have selected. It then sets 2 corresponding "hidden" form elements to the...
4
by: Otis Hunter | last post by:
I have been fighting with this for days and your expert help is needed! Below is the code I am executing which results with "Object doesn't support this property or method". The error is occuring...
2
by: todd | last post by:
Hi all. I inherited this code from a contractor. It is a .NET user control that runs on the client side (ie) on machines with the framework installed. I have been mucking around to get it work...
5
by: monu121 | last post by:
hi, i am getting one error "Object Does Not Support This Property or Method..." when i am using my dll file actuly i am calling my dll file in product. i am using vb 6.0. if any one is...
1
by: hhackwell | last post by:
Hi guys, I'm running a simple piece of Javascript on my website to allow users to make an object appear when they want to use it. It works fine but I keep getting this error on IE and although...
1
by: chetan7991 | last post by:
I'm using a jquery plugin Galleriffic in my page and it shows perfectly in all browsers except IE. The error says: "Object doesn't support this property or method" The code I use for script...
2
by: simeric | last post by:
Hi all experts, I've "object doesn't support this property or method" error when running a Javascript on Internet Explorer 8 This is the statement that is having the error:- ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.