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

javascript, replace works only with FF, why?

P: n/a
Hello,

I want to remove from string a <span> tag, but with leave the value of
that tag.

I have that code:

theExp = new RegExp("<span>", "g");
txt = txt.replace(theExp, "");

theExp1 = new RegExp("<\/span>", "g");
txt = txt.replace(theExp1, "");

and this works only with FF,
With IE it doesn't remove the tag.
With Opera the same

thanks a lot for help and sorry form my english

--
best regards
Artur

Jun 29 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a


ar*********@gmail.com wrote:
theExp = new RegExp("<span>", "g");
txt = txt.replace(theExp, "");

theExp1 = new RegExp("<\/span>", "g");
txt = txt.replace(theExp1, "");

and this works only with FF,
With IE it doesn't remove the tag.
With Opera the same


What is the initial value of txt then you try with? I have no problems
with IE or Opera with for instance the initial value
var txt = '<span>Kibology for all.</span>';
Which is the exact version of IE and Opera that code allgededly fails with?
I have tried with IE 6 and Opera 9.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 29 '06 #2

P: n/a
> What is the initial value of txt then you try with? I have no problems
with IE or Opera with for instance the initial value
var txt = '<span>Kibology for all.</span>';
Which is the exact version of IE and Opera that code allgededly fails with?
I have tried with IE 6 and Opera 9.


thanks for help;
In my example I directly use labels[i].innerHTML insted of txt (as
txt=labels[i].innerHTML).
Where I do that everythink is ok

--
regards
Artur

Jun 29 '06 #3

P: n/a
"siara" <ar*********@gmail.com> writes:
thanks for help;
In my example I directly use labels[i].innerHTML insted of txt (as
txt=labels[i].innerHTML).


Then the most plausible explanation is that IE's and Opera's innerHTML
produces tags in upper case.
A quick check shows that it is at least the case for Opera.

You can add "i" to the flags of the regexps to ignore case.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 29 '06 #4

P: n/a

Lasse Reichstein Nielsen wrote:
"siara" <ar*********@gmail.com> writes:
thanks for help;
In my example I directly use labels[i].innerHTML insted of txt (as
txt=labels[i].innerHTML).


Then the most plausible explanation is that IE's and Opera's innerHTML
produces tags in upper case.
A quick check shows that it is at least the case for Opera.

You can add "i" to the flags of the regexps to ignore case.

ok, I will remember that, thanks

Jun 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.