I have done text replacement in Javascript such that the <br />
tag will be replaced by the \n\r
. This seems to work in IE8.0 but not in chrome and firefox. why is that so? How can I make it work in chrome and firefox. Why does chrome and firefox not consider <br/>
tags as <br/>
but rather <br>
?
Asked
Active
Viewed 1,498 times
0
-
1What do you need this for? Can you elaborate on your situation? There may be a better/easier way for what you want to do. – Pekka Oct 06 '11 at 09:31
-
In the future, you really need to show the code that isn't working. – Tim Post Oct 06 '11 at 13:17
1 Answers
2
This seems to be working fine everywhere:
"Hello<br />World".replace(/<br\s*\/?>/ig, "\r\n");

voldomazta
- 1,300
- 1
- 10
- 19
-
Sometimes simple mistake happens like : Some one can use "" , in this case use replace(/<\s*\/?br>/ig, "\r\n") – eegloo Nov 11 '13 at 10:24
-