IE8 PRE Tag Problems

By : Abilash

I referred to the other discussion which is on similar lines. Here is the link for that discussion.

code inside pre goes in one line on IE8

The outer HTML works fine. But my requirement is for inner HTML. The reason for not using outer HTML is that I'm using AngularJS which has conditions on the HTML itself. So I need to add the content to the innerHTML.

Here is the HTML.

<p ng-show="preview=='text' && !file.showUploadPanel && file.fileContent!='null' && file.fileContent!='undefined'" ng-bind-html-unsafe="file.fileContent" class="pre fileContent"></p>

Here is the JS that is supporting it.

var elem = $(".pre.fileContent")[1];
if (elem.tagName == "P" && "innerHTML" in elem){
    elem.innerHTML = "<pre>" + elem.innerHTML + "</pre>";

I've also tried replacing "<pre>" + elem.innerHTML + "</pre>" with the scope variable which results in "<pre>" + $scope.file.fileContent + "</pre>";

Here is the error that I'm getting on IE8.

Error: Unknown runtime errorundefined

If I remove <pre> from the elem.innerHTML the error doesn't occur. Also, for outerHTML, this error doesn't show up.

How should I tackle this?

By : Abilash


Sorry I am confused with the paragraph class selector,

This video can help you solving your question :)
By: admin