Jump to content

A way to dynamically view a live source of a .html page??


dsaba

Recommended Posts

Many ajax and javascript functions change the innerHTML of elements in the source, writing and rewriting things in the source

 

You can run any javascript function or action you want that would change the source, but when you view it, it will always show the original source before a JS function changed it

 

Is there a way to view the changed source after each time a JS functoin changes it??

 

for example:

<span id="whatever">This is the original source code</span>

 

then you may run this piece of JS:

whatever.innerHTML= 'Changed source code!';

 

 

but when you right click and press 'view source"

you will always get this:

<span id="whatever">This is the original source code</span>

 

I want to get the changed source code, maybe its possible to write the changed source code to another file, or use some kind of HTTP prog to read the changes on an html page???

 

Any help appreciated :) thanks

I found this to work:

<html>
<head>
<script type="text/javascript">
//document.open('text/plain').write(document.documentElement.outerHTML);
function change_span() {
whatever.innerHTML= 'The changed source code!';
}

function get_source() { 
window.open().document.open('text/plain').write(document.documentElement.outerHTML);
}
</script>
</head>
<body>
<span id="whatever">Original Source!</span>
<script>
change_span();
get_source();
</script>




</body>
</html>

 

 

but is there a better way to do this and if possible can I write it to a .txt file???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.