Im trying to get pretty.js to prettify code in CODE tags, using this js:
onload_functions.push(function() {
var node_list=document.getElementsByTagName('code');
for (i=0; i < node_list.length; i++) {
node_list[i].setAttribute('class','prettyprint');
}
prettyPrint();
});
This works fine for Firefox :) but IE's having none of it. What am i doing wrong?
You can see it (non)working at http://sam.xnet.tk
If the code element has any other class names, this will yield chaos in IE. Using the (IE-specific) JavaScript property className
will likely work.
I commented on the onload
function on your website.
Btw, the way you embed the JavaScript it will break future standard-compatible browsers, see the W3C validator's output for your site. The easiest solution is to move the code to an external file.