Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Thanked 2 Times in 2 Posts

    approach to online javascript editing?

    I'm almost positive this question will make you groan "neewwwbie!"....

    I have a simple javascript that decides which 'div' to make visible, based on another element within the html.

    What i want now is to create a page where someone can view all the possible divs in that javascript that might appear and edit them (including href's, ital, bold and image tags.) Much like a CMS system, but the information is within a javascript, not a database.

    I would assume it's possible. What's a good way to approach this? It sounds like Javascript cannot edit .txt files. Is there a way to have the user access and edit an .xml file and just pull that into the div tag, instead of text?
    Last edited by turpentyne; 09-22-2011 at 07:16 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,650 Times in 4,612 Posts
    Short answer: No.

    Oh, the user could modify the contents of XML or the contents of a <div> or or or ...

    But then what?

    *ONLY* that user could see the results of that modification. (You could use cookies to save the user's changes from one session to the next, so at least the user's changes could persist...until he/she deletes the cookies!)

    No other user could see the changes.

    For that, you *MUST* use some server-side system to store the changes. PHP/ASP/JSP/whatever. Any of them could work. But *not* JavaScript with HTML, alone.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Thanked 600 Times in 580 Posts
    would they be changing the page for just themselves, or would changes need to be shared with everyone?

    both are possible with js, though to share with others, youll need to use a webservice like google doc's forms to save and YQL to pull it back out.

    if it's all local, it's trivial: look into window.localStorage
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts