By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

replace method and array value

P: n/a
JAG
I am getting an error using the replace method in one of my functions.

I am using the replace method in the mail document function in my
frameset .hta to change forward slashes to back slashes in the myVar
string.

The myVar string is obtained in my show document function:
myVar = filename;

In my mail document function:
myVar = myVar.replace(/\//g,"\\");

This works as expected.

I have a history function that gets called when the back button is
clicked in my .hta. The myVar variable then gets its value from my
history array:
myVar = myLink[n].href;

When the mail document function is invoked and the replace method
called I get the error 'Object doesn't support this property or method'
on the replace line.

I have verified the myVar string both with and without using the
history function and both return identical strings (at least visually
in my alert dialog).

Does anyone know why the replace fails when myVar gets its value from
my history array? Must be something fundamental I'm missing but I can't
figure out what it is.

Thanks in advance for any help.

Sep 22 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JAG

Lee wrote:
JAG said:

I am getting an error using the replace method in one of my functions.

I am using the replace method in the mail document function in my
frameset .hta to change forward slashes to back slashes in the myVar
string.

The myVar string is obtained in my show document function:
myVar = filename;

In my mail document function:
myVar = myVar.replace(/\//g,"\\");

This works as expected.

I have a history function that gets called when the back button is
clicked in my .hta. The myVar variable then gets its value from my
history array:
myVar = myLink[n].href;

When the mail document function is invoked and the replace method
called I get the error 'Object doesn't support this property or method'
on the replace line.

I have verified the myVar string both with and without using the
history function and both return identical strings (at least visually
in my alert dialog).

Apparently myVar is not a string.
My guess is that it's a Location object.
It will appear to be a string in an alert, because what you actually
see is the result of its toString() method.

myVar.toString().replace(...)
--
Your guess was correct, apparently. Adding toString() gave me the value
I was looking for. Thank you for the prompt help.

So my array value , which I assigned to myVar, is a location object.
Guess I've got some reading material tonight. Thanks again for your
help.

Sep 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.