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

Replace method of String object doesn't work

P: n/a
It looks like the String.replace doesn't work in IE6.1. Anyone else
has the same problem. I am using newest service package of IE and
Win2K.

Thanks
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Thomas wrote:
It looks like the String.replace doesn't work in IE6.1. Anyone else
has the same problem. I am using newest service package of IE and
Win2K.

Thanks


There are a number of issues going on here.

One, there is no such thing as IE 6.1, the latest version of IE is 6.0
Service Pack 1.

Two, just because you are running IE 6.0SP1 does not guarantee that you
are running JScript 5.6, the way to verify this is to go to:

Start -> Run -> type "cmd", hit Enter
type "cscript", hit Enter
You should see something similar to "Microsoft (R) Windows Script Host
Version 5.6", the number you see there is the version of JScript you are
using. If it's anything other then 5.6, check <url:
http://msdn.microsoft.com/library/en...nformation.asp
/> to see if String.replace() is a supported method for your version of
JScript (hint: replace() has been a method of the String object since
JScript 1.0).

Three, alert("My String".replace(/String$/, "New String")); works just
fine.

Four, note that String objects are immutable, that is, you don't modify
the original String when you call replace(), but instead a new String
object is returned that contains the replaced String.

var s = "My String";
s.replace(/String$/, "New String");
alert(s);
// alerts "My String"

var s = "My String";
s = s.replace(/String$/, "New String");
alert(s);
// alerts "My New String"

In the future, instead of simply stating that some method doesn't work,
perhaps you could include the simplest example of your code that
exhibits the incorrect behaviour. Often the very act of simplifying your
code to demostrate the problem reveals the cause of the problem.

--
| 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 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.