0

I'm currently working on a web page that will dynamically update itself. I was using the innerHTML function to access elements of the page, and then update them by changing their innerHTML. However, to my dismay, this only allowed for temporary changes.

Is there any similar function that would allow me to permanently change the contents of an HTML file? Note that the application I have in mind would not be able to access a server.

SyntaX
  • 2,090
  • 17
  • 30
S.T.
  • 31
  • 2
  • 4

2 Answers2

0

the only thing i can think of that might help you would be a browser addon that will execute the javascript every time you visit the page...

something like: https://addons.mozilla.org/en-us/firefox/addon/dotjs/

Bill Brasky
  • 155
  • 3
0

The exact answer depends on what kinds of changes you want to make. But if you want the page to look different to everyone who sees it, the usual pattern is that users submit content, which is stored in a database, and then the database content is displayed on the page, usually contained in neat rectangles.

In most contexts for security purposes the programmer should avoid having user-provided content affect the page except in limited ways. A bad idea would probably be to have users submit arbitrary javascript programs and then run them in the window when the page loads, for example - that would likely let them mess up the page more than any reasonable site would like to allow. And you never want to directly execute PHP or SQL that that users entered, unless you are trying to teach the users to do hacking.

So then the general plan might be something like this: 1) Set it up so users can enter some specifications for the changes to be made (could be anything like change colors, add things to the page, put images, fonts, specific HTML tags, specific transition filters, maybe even add divs and tables etc, just not add general javascript because it could get too crazy) 2) Set up the page to follow the instructions intended by the users, so the page is changed according to the system, according to the changes their content is indicating

If the user content controlling the changes is permanent, then the changes to the page will be permanent too.

An example is the Million Dollar Home Page, where he sold pixels for $1 each, for advertising. Once each pixel was sold, the dude updated the image permanently, and that's how he got his $1million. But I'm sure in that case files were changed on the server when the php program ran.

Thinkadoodle
  • 512
  • 1
  • 4
  • 11