Jump to content


Charactor Replacing in HTML (Cross-Browser Code) How?


2 replies to this topic

#1 alMubarmij

    Newbie

  • Members
  • Pip
  • 0 posts

Posted 29 December 2006 - 08:36 PM

Hi ..

I have an idea to replace some charactor by another one in web pages by JavaScript.

Example(1) - One Charactor Replacing :
--------------------------------------
I need to replace:
any "#" charactor to "@"
any "n" to " " ,
and any "001" to "&".

Example(2) - Word or Phrase Replacing :
--------------------------------------
Replacing a list or array of bad words to other words.


I don't know how I can do that for all document items like: <body>,

<td>, <th>, <div>, <span>, <p> and so on.
but I need to check a full HTML page not only those tags.
Also I need a cross-browser code using DOM.

I think we can use something like this:
  
item.innerHTML

or:

document.layers.innerHTML // for Gecko engine browsers.
document.all.innerHTML // for IE browser.
 

I can do this simply in PHP language functions like str_replace()

but it's a server-side language, I want a cleint-side method by JavaScript.

Can any JavaScript professional help me ?

#2 lampchaitanya

    Advanced Member

  • Members
  • PipPipPip
  • 88 posts

Posted 30 December 2006 - 05:57 AM

hi,

try htis link..

http://www.novell.co...sJS.html#978290

http://www.quirksmod...ngs.html#substr

#3 alMubarmij

    Newbie

  • Members
  • Pip
  • 0 posts

Posted 31 December 2006 - 03:45 PM

Thanks I checked them..
but do you have more details or other methods ?
I want to replace from all page not just a small string.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users