I have an element in my html-code, that holds a completely new html code written by a user, for previewing after codeing into a textarea (simple: a web-editor).
My problem starts when the user types in his code with an id or/and a class, that is already in my code.
So imagine this:

<html>
<body>
<div id="hi">That is my text</div>
<textarea id="here_writes_the_user_his_code"></textarea>
<section id="user_input">
<!-- All following is from the user...-->
  <html>
   <body>
     <div id="hi">Too bad, hi has already been used...</div>
   </body>
  </html>
<!--...til here!-->
</section>
</body>
</html>

Any idea of solving this?

Well, assuming they are pasting in an HTML page, that's to be expected. It's also to be expected if you are using an iFrame to display their content. On the other hand, if all you are doing is displaying what THEY WROTE into the textarea (and you are 100% sure they didn't write html tags, you must be inserting it in some way we don't have any idea about.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.