Help with OBJECT DOESN"T SUPPORT

P

Paul Reed

Hello,

I have a function that runs at load time and throws a an "Object Doesn't
Support This Propertiy or Method" jscript error.

The offending line is "if (type != "undefined") ". If I change the check to
"type != """...I get no error...any ideas?

var thePath = "";
var type = ""
var type = typeof parent.ory_button;
if (type != "undefined") {
type = typeof parent.ory_button.getTreePath();
if (type != "undefined") {
thePath = parent.ory_button.getTreePath();
}
}
document.write(thePath);
 
D

Dom Leonard

Paul said:
I have a function that runs at load time and throws a an "Object Doesn't
Support This Propertiy or Method" jscript error.


var thePath = "";
var type = ""
var type = typeof parent.ory_button;
Comment: defining the same variable twice is not useful. Simply omit the
first declaration assigning the null string.
if (type != "undefined") {
type = typeof parent.ory_button.getTreePath();
This line is calling the getTreePath method instead of ascertaining if
it exists. Try
type = typeof parent.ory_button.getTreePath; // then:
if (type != "undefined") {
thePath = parent.ory_button.getTreePath();
}
}
document.write(thePath);

Alternatively, try:

var thePath = "";
if(parent.ory_button && parent.ory_button.getTreePath)
thePath = parent.ory_button.getTreePath();
document.write(thePath);

HTH
Dom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,207
Latest member
HelenaCani

Latest Threads

Top