简体   繁体   中英

Need to preview html entered in a form by clicking a button

I'm working with some code and what I want to do is straightforward. There is a form box for users to enter html into. When the preview button is pressed, a preview of the page created by the html will be displayed, either in a new tab or in a pop up. Any help would be greatly appreciated. I'm working in .Net but can also use javascript. Thanks

-Matt

Not sure how this will fit into your work but it will get you going.

 function renderHTML(){ var html = document.getElementById("writtenHTML").value document.getElementById("preview").innerHTML = html; } 
 #writtenHTML{ width:400px; height:400px; } 
 <textarea id="writtenHTML"></textarea> <button onclick="renderHTML()" type="button">Click Me!</button> <div id="preview"></div> 

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM