How to edit html pages using javascript?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
hush2
Forum Newbie
Posts: 1
Joined: Wed Aug 11, 2010 4:36 am

How to edit html pages using javascript?

Post by hush2 »

I want to create a webpage (using javascript) to edit and retrieve the data of another webpage. I also want that after closing the webpages, the edited data remains on the page.
User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: How to edit html pages using javascript?

Post by PHPHorizons »

Hello hush2,

This is complicated... I'll outline the basic idea, as I understand what you want to do. You will need to create a proxy script on your server. This can be a php script, or any other server side scripting language. That page should accept one GET or POST argument specifying a page to load. I would highly recommend that you whitelist the pages that are aloud to be loaded through that proxy. You could black list, but please save yourself a lot of trouble, and just make a whitelist. This proxy will then be used by an ajax based javascript.

Alrighty, so that's the backbone of this, now let's look at the front end. The front end will use javascript (ajax) to connect to the proxy and that will load the web page that is needed. It will then return that webpage's contents to the javascript script. Then you can edit it using whatever kind of editor you like (I'd check out a Rich Text Editor from one of the JS libraries).

Lastly, you need another server side php (or other language) script that the javascript script can submit the data to. Then you need to save that data. You can save it as either a file, or in a database.

Cheers
Post Reply