Ok,
Here is some code I have found and was trying to use, however this will display the code for the entire page, I only want to display the code that is displayed between <code></code> on the page.
Code:
<script type="text/JavaScript">
/* View Source by: robbie lemon
rob.lemon@gmail.com */
window.onload=function(){
var a = document.createElement('a');
a.href="javascript:void(0);";
a.appendChild(document.createTextNode('View Source'));
document.body.appendChild(a);
a.onclick=function(){
var p= document.createElement("p");
var source = "<code>" + document.documentElement.innerHTML + "</code>";
source = source.replace(/</g,"<");
source = source.replace(/>/g,">");
source = source.replace(/\t/g," ");
sourceTemp = source.split("\n");
source = "<table cellpadding=\"0\" cellspacing=\"0\" style=\"border: 1px solid #000000; background-color:#efefef;\"><tr><td nowrap>line #</td><td></td><td></td></tr>";
for(i=0;i<sourceTemp.length;i++){
// remove the nowrap property from the below line if you want word-wrap
source+= "<tr><td align=\"center\">" + Math.round(i+1) + "</td><td>: </td><td>" + sourceTemp[i] + "</td></tr>";
}
source+="</table>";
p.innerHTML = source;
document.body.appendChild(p);
}
}
/* End of View Source script */
</script>
And here is s sample of the output I want to have shown as source code on the page.
Code:
<code><table style="width: 100%;" cellpadding="2" cellspacing="0">
<tbody>
<tr>
<td rowspan="4" style="border-top: 1px solid #000000; border-left: 1px solid #000000;" width="34%"><span class="sdcaption">Sire: :</span> firstS</td>
<td rowspan="2" style="border-top: 1px solid #000000; border-left: 1px solid #000000;" width="33%"><span class="sdcaption">Sire: :</span> SecondS</td>
<td style="border-top: 1px solid #000000; border-left: 1px solid #000000;" width="33%"><span class="sdcaption">Sire: :</span> ThirdS..... </code>
Bookmarks