Jump to content

help using js and dom to display information help please


meomike2000

Recommended Posts

on a page that i am working on i use js to create all the elements and then append the information that  is retrieved via php from the database....

 

how can i defang the html that may get entered by a user.....

if the information was displayed with via php i would use something like print htmlentities($users value here); and it would make the html that a user may enter not work....

 

how can i do the same thing in js......

 

so that if a user enters something like value <br> value it would get displayed

as :

value <br> value, and not as,

value

value

 

any help would be great mike......

well this worked but did not give the affect that i was looking for.....

var s = whatever;

s = s.replace('<','<').replace('>','>').replace('&','&');

 

so i added another line like this and for some reason it works and kills the html tags in fire fox and ie.

 

var s = whatever;

s = s.replace('<','<').replace('>','>').replace('&','&');

s = s.replace('<','<').replace('>','>').replace('&','&');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.