简体   繁体   中英

Retrieve html from textbox and display in popup

I'm retrieving a string from a textbox which will contain html eg <html><head><body><div></div></body></head></html> .

Basically i have got the content from the textbox, but cant get the popup to display like a html page.

In my jquery code i have

          var html = document.getElementById('<%=txtHtmlBody.ClientID%>').value;
          $(html).dialog();

At the moment the content looks like it is squashed into a small box, with a transparent background. How can i get this to display like a html page in a popup?, any help is appreciated Thanks in advance

You need a div that is filled with the contents of your textbox.

var myhtml = document.getElementById('<%=txtHtmlBody.ClientID%>').value;
$('#mydiv').html(myhtml);
$('#mydiv').dialog();

you should add one empty element in your page.

<div id="dialog"></div>

so, put value of field into your element, and show this:

$('#dialog').html($('#<%=txtHtmlBody.ClientID%>').val());
$('#dialog').dialog();

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