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

javascript, replace works only with FF, why?

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
4 4516


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
> 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
"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

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

Similar topics

0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.