Perfect. Thank you, I did try using a $.get request but I was tyring to replace charecters instead of injecting the data as text. This is exactly what I was trying to do. I thought there was a very simple and clean way to do it but I wasn't sure how. Thank you much!
On Apr 4, 12:08 am, Abdullah Rubiyath <alif...@gmail.com> wrote: > Hi There, > > If I am getting this right.. you are trying to get the contents of > another file and inject it into an element, but ensuring it shows as > plain text and javascripts are not executed. > > Can you try replacing $('#thisDiv').load with a $.get request and do > the following: > > $.get('../sample.html', function(data) { > $('#thisDiv').text( data ); > > }); > > With this approach, the html entities (<,&,> etc.) will be converted > to their appropriate characters and then injected to $('#thisDiv'). > > I hope this helps, > > Thanks, > Abdullah. > > On Apr 3, 11:27 pm, Nikola <nik.cod...@gmail.com> wrote: > > > > > Anyone have any ideas or input on this one? > > > On Apr 3, 6:29 pm, Nikola <nik.cod...@gmail.com> wrote: > > > > Thanks MorningZ, I gave this approach whirl and in a roundabout sort > > > of way it seems to accomplish the same thing I was doing in my third > > > example. > > > > $("#thisDiv").load("../sample.html", { }, function() { > > > var div = document.createElement("div"); > > > var text = document.createTextNode($("#thisDiv").html()); > > > div.appendChild(text); > > > var EscapedHTML = div.innerHTML; > > > $("#thisDiv").text(EscapedHTML); > > > > }); > > > > In a nutshell I want to display the text of an HTML file as plain > > > text. I'm able to do this, with HTML, but I'm unable to prevent the > > > javascipt in the HTML from executing. My goal is to write a simple > > > function that loads code from a document and displays it as text.- Hide > > > quoted text - > > - Show quoted text -