473,387 Members | 1,512 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,387 software developers and data experts.

replace method and array value

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
1 1976
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Barnes | last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form? Here is the scenario: I have a form that cannot accept apostrophes. I want to use the replace() so...
5
by: K.Simon | last post by:
Hello, it's very often neccessary to replace strings or a single character in my stylesheets. My solution looks awful and very long. Now i thought to solve this with an array like structure but...
6
by: vigi98 | last post by:
Hello all, Can someone confirme that this: var strURLpiece = "UK & Ireland"; strURLpiece.replace("&", "%26"); replaces all occurrence of the character & by %26 in strURLpiece, ie that...
2
by: Barnes | last post by:
Hi, Can anyone please tell me how I can use the replace method to replace a character if it occures in more than one textbox without having to write separate function for each textbox. The...
3
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some...
3
by: Roy W. Andersen | last post by:
Hi, I need to do some replace-calls on certain strings in order to replace smiley glyphs and other keywords with graphical icons on the client. Unfortunately, my knowledge of regular expressions...
14
by: Adrienne Boswell | last post by:
Although this is a client side issue, I am also posting to asp.general in case there is someway to do this only server side (which I would prefer). Here's my form: <form method="post"...
10
by: Lonifasiko | last post by:
Hi, Just want to replace character at index 1 of a string with another character. Just want to replace character at that position. I thought Replace method would be overloaded with an index...
1
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "":...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.