0

I was trying to change my HTML files. Please see this to get a better understanding of what I am up to.

Every thing worked fine but as I viewed the source it was not changed. The changes I was trying to make were only reflected on the web-page I had opened on my browser.

Is it by any way possible to change the actual source of the HTML page?

I am using IE8 and GreaseMonkey4IE to run my JavaScript on the web pages I want to manipulate, just in case you are interested.

There is a similar question here. But I have my HTML files at my local storage. No server side - client side technicalities.

EDIT 1

Well I do have setup Tomcat but it is all in my local machine.
Also if I can modify the DOM can't I save it as a new HTML file, this way I won't have to mess with the original source file.

This is how we do it in firefox. There must be some way to do it in IE8.

EDIT 2
Now it is working fine for the HTML pages without any frames. But when I am trying this on pages with frames it is not working.It is going to kill me i am sure. Perhaps this is because frame access other HTML pages. For example :

<frameset rows="95,*" frameborder="NO" framespacing="0" border="0" marginwidth="0"  marginheight="0">
    <frame name="title" target="content" src="Strategy%20Details.asp_files/title.htm"  scrolling="NO">
 <frameset cols="168,*">
   <frame name="navigation" noresize="noresize" width="168" target="content" src="Strategy%20Details.asp_files/navigation.htm">
   <frame name="content" noresize="noresize" src="Strategy%20Details.asp_files/home.htm">
 </frameset>
 </frameset> 



See how the frames are accessing the HTML pages in src attribute.

Any Idea ???

5
  • 4
    The source is the source, the DOM is the DOM. You can't change the source except with an editor. Commented Sep 27, 2011 at 11:30
  • 1
    It is called "source" for a reason. Commented Sep 27, 2011 at 11:32
  • I am deploying the file on tomcat though, Coz greasemonkey4IE needs a domain to apply the javascript on.Is this why I am unable to change the source? Commented Sep 27, 2011 at 11:38
  • @mohit Because you can't change the source through JavaScript, you change the source through an editor. With JavaScript you're modifying the DOM--the object model created by the browser from the source. Commented Sep 27, 2011 at 12:28
  • it seems some fool is too busy messing with the Question votes.Please devote your energy to help instead of doing the reverse. Commented Sep 27, 2011 at 12:56

5 Answers 5

3

You should be able to see the dynamic changes using IE Developer Tools.

When you "View Source" the page shows you the source that was delivered from the server without any changes made afterwards. IE Developer Tools (or Firebug in Firefox, or Dragonfly in Opera) will let you see changes dynamically (and will also highlight changes as they occur!)

Sign up to request clarification or add additional context in comments.

5 Comments

But what about element.value=""; if I have changed the value to blank and my browser displays that, shouldn't I be able to save that file maybe with a new name.
@mohit You might be able to get the DOM as HTML (like using Firebug or equivalent) and save that. But it's not clear what you think you'd be saving.
@Dave what is firebug's equivalent for IE8.
The Native Equivalent of fire bug in ie is developer tools. Press f12
+1 for your help.I wish I could accept 2 answers or may be more.Thanks
1

If I understand you correctly you want to change the contents of the HTML file on your harddrive? That's not possible using JS, and regardless of where the HTML file is (local machine or not), there's always a server side and client side. Basically your OS is acting as the server (providing you with HTML) and your browser is still just a client, with no more rights than it would have if you were on a page on the web.

It sounds like you should look in to some kind of server technology that allows for dynamic web pages such as PHP, JSP, server side JS, or any of a million others.

Comments

1

So from looking at what you are doing with Firefox, you don't want javsctipt to do the saving, just be able to modify the DOM using script the Save the HTML representation of the changes in IE.

IN IE, use IE developer tools. Press f12. If you've manipulated the DOM, click the refresh icon in developer tools. Then Click the save icon.

1 Comment

ohh.. it seems you were just few seconds late, but this by no way diminishes your effort.
0

Edit: No there isn't a way, atleast not without inspecting source without firebug.

Comments

0

It isn't possible. I suppose it depends on the browser, but when you request the source of a page, they usually perform the request again, or use a cached result of the original source (evidently before client manipulation, which only exists and makes sense in your view of the page in your browser), so you get what you have in the source (in this case the HTML files in your local storage).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.