On my page, I have a text area which contains HTML code. How can I add a 'Preview' button (preview must open in a new window)?
Instead try using a online WYSIWYG editor such as TinyMCE. [http://tinymce.moxiecode.com/] Else you will have to POST the contents of the textarea to a script! <!-- XHTML code --> <form name="myform" id="myform" action="preview.php" method="post"> <textarea rows="25" cols="80" name="htmlarea" id="htmlarea"></textarea> <input type="submit" value="Submit" /> </form> HTML: <?php //code for preview.php echo $_POST['htmlarea'];//you may need to use stripslashes() depending upon magic quotes configuration! ?> Code (PHP): Also, not all user agents may render it properly due to quirks mode. Your best option, I think, would be to use TinyMCE!