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

Link to comment
Share on other sites

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???

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.