Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / June 2006



Tip: Looking for answers? Try searching our database.

javascript, replace works only with FF, why?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
artur.siara@gmail.com - 29 Jun 2006 12:27 GMT
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

Signature

best regards
Artur

Martin Honnen - 29 Jun 2006 13:12 GMT
> theExp = new RegExp("<span>", "g");
> txt = txt.replace(theExp, "");
[quoted text clipped - 5 lines]
> 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.

Signature

    Martin Honnen
    http://JavaScript.FAQTs.com/

siara - 29 Jun 2006 14:32 GMT
> 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

Signature

regards
Artur

Lasse Reichstein Nielsen - 29 Jun 2006 17:35 GMT
> 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
Signature

Lasse Reichstein Nielsen  -  lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
 'Faith without judgement merely degrades the spirit divine.'

siara - 30 Jun 2006 15:15 GMT
> > thanks for help;
> > In my example I directly use labels[i].innerHTML insted of txt (as
[quoted text clipped - 5 lines]
>
> You can add "i" to the flags of the regexps to ignore case.
ok, I will remember that, thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.