Leo Gasparrini
Leo Gasparrini

Reputation: 171

Prevent <script> execution after use html() function

I have a widget that replace some text contents to my clients in a particular section. So to achieve it I need to use html() method that replace all with the new content, but after this, If my client has <script> ... </script> these are executed again!

is there any way to prevent the execution of these scripts?

I would apreciate any help! Thanks

Upvotes: 0

Views: 302

Answers (2)

sdc
sdc

Reputation: 3011

You can load your client's code into an <iframe> and use the sandbox attribute to prevent the client's js execution. The <iframe> element provides security against XSS.

Upvotes: 0

Leo Gasparrini
Leo Gasparrini

Reputation: 171

As @T.J. Crowder said... removing the scripts was the better solution. thanks man =)

Upvotes: 1

Related Questions