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

Link to comment
Share on other sites

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('&','&');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.