Setting pretty printable tags via javascript
Im trying to get pretty.js to pre-refine the 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 great for Firefox :), but IE has nothing. What am I doing wrong?
You can see this (not) by working at http://sam.xnet.tk
0
source to share
2 answers
If the code element has other class names, it will wreak havoc on IE. Using a (JavaScript-specific) JavaScript property className
will most likely work. I have commented on a feature onload
on your site. By the way, the way you embed JavaScript, it will break future standard compliant browsers, see the output of the W3C validator for your site . The simplest solution is to move the code to an external file.
0
source to share