...

View Full Version : How to Use HTML Inside a Text Area Box



Four750
07-29-2009, 09:03 AM
Hi,

I have the following form. The html file was saved on my HD and in true it is a full text.

Now I want to see that file inside the <textarea> when the user on click that link and at the same time shows the textarea (instead onclick checkbox).


<form>
<A HREF="ww_HTMLView.html">ww_HTMLView.html</A>
<input type="checkbox" onclick = "urltxt.style.visibility = (this.checked) ? 'visible' : 'hidden'" />
<textarea name="urltxt" style="visibility:hidden"></textarea>
</form>

Four 750

abduraooft
07-29-2009, 09:47 AM
How about using an iframe (http://www.w3schools.com/TAGS/tag_iframe.asp)?

Four750
07-29-2009, 02:14 PM
Hi,

I would need to open in a textarea such page.



Four 750

jmrker
07-30-2009, 04:01 AM
Could use ajax to read and display the HTML text
but it will NOT execute from the <TEXTAREA>.

The <iframe> would be used to display and act on the HTML.

Four750
07-30-2009, 07:35 AM
Hi,

I believe I am was too clear. The SOURCE CODE of that HTML PAGE in TRUE are in text format. In other words. No TAGS. It is simply text.

Four750

Philip M
07-30-2009, 07:47 AM
Hi,

I believe I am was too clear. The SOURCE CODE of that HTML PAGE in TRUE are in text format. In other words. No TAGS. It is simply text.

Four750

If it is simply text, why is it not a .txt file?
You will need AJAX to read and display a text file.

If you use an iframe (as suggested) then you can dsiplay the content as follows:-


<textarea id = "txt1" rows = 30 cols = 60></textarea>

<script type="text/javascript" >
window.onload=function(){
var str = document.getElementsByTagName('html')[0].innerHTML;

// edit str as required to remove tags etc.

document.getElementById("txt1").value = str;
}
</script>

You could use a hidden iframe and then copy the HTML from all or part of the iframe to a textarea.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum