Thomas Darimont
Erfahrenes Mitglied
Hallo!
Danke Gumbo ich schau gleich mal rein,
in der Zwischenzeit hat Fabian Hoffmann alias Nuimundo dies hier gezaubert:
Gruß Tom
Danke Gumbo ich schau gleich mal rein,
in der Zwischenzeit hat Fabian Hoffmann alias Nuimundo dies hier gezaubert:
HTML:
<html><head><title>Code Listing</title>
<style type="text/css">
code.HighlightCode {
display: block;
margin-left: 5em;
}
div.HighlightCodeLines {
font-family: monospace;
float: left;
width: 4.5em;
text-align: right;
}
</style>
<script type="text/javascript">
function addLineNumbers(el)
{
/* hier lassen sich natuerlich auch LFs matchen */
var nls = el.innerHTML.match(/<br( ?\/)?>/ig);
if (nls.length < 0)
return false;
var nlcnt = nls.length + 1;
var lines = window.document.createElement('div');
/* setAttribute doesn't work properly for IE */
lines.className = 'HighlightCodeLines';
for (var i=0; i<nlcnt; i++)
lines.appendChild(createLineNumber(i+1));
el.parentNode.insertBefore(lines, el);
}
function createLineNumber(n)
{
var line = window.document.createElement('div');
line.appendChild(window.document.createTextNode(n.toString(2)));
return line;
}
function blahfasel()
{
var c = window.document.getElementsByTagName('code');
for (var i=0; i<c.length; i++)
addLineNumbers(c[i]);
}
</script></head><body onload="blahfasel();">
<h1>Code Listing Example</h1>
<code class="HighlightCode">
Code Zeile 1<br>
Code Zeile 2<br>
Code Zeile 3<br>
Code Zeile 4<br>
Code Zeile 5<br>
Code Zeile 6<br>
Code Zeile 7<br>
Code Zeile 8
</code>
<p>
Text, blah blah fdsfdsf
</p>
</body></html>
Gruß Tom