www.webdeveloper.com
Results 1 to 4 of 4

Thread: Save HTML/Javascript to database using innerHTML

  1. #1
    Join Date
    Oct 2009
    Posts
    3

    Save HTML/Javascript to database using innerHTML

    Hello All,
    I am trying to save HTML (including all of the events) to an Oracle database. I can make this happen by getting innerHTML and using the javascript replace method to "re-add" my event handlers to my html string before writing it to the database. This is cumbersome and fairly messy. I am wondering if anyone has done anything like this before, or is there another way to capture the HTML (without using innerHTML) that would contain the events so that I did not have to use "replace" to update my string.

    Thanks for the help.

    Here is a streamlined version of my code:
    element_html=tr1.innerHTML;
    var str1="id=rowid_1"; //string to replace
    var str2="id=row_id_1 onclick=alert("hello"); //replace str1 with this
    element_html=element_html.replace(str5, str6);
    write element_html to oracle database

  2. #2
    Join Date
    May 2003
    Location
    Between Baltimore and DC
    Posts
    3,579
    Why are you doing this? Seems like a nice security hole to me that can be exploited by hackers.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint] | twitter | linkedin | http://www.pascarello.com

  3. #3
    Join Date
    Oct 2009
    Posts
    3
    I'm doing this because I am building a form builder application that allows users to build their own forms, which will be saved as html, and also can be opened again for editing.

    BTW, the code should read
    element_html=tr1.innerHTML;
    var str1="id=rowid_1"; //string to replace
    var str2="id=row_id_1 onclick=alert("hello"); //replace str1 with this
    element_html=element_html.replace(str1, str2);
    write element_html to oracle database

  4. #4
    Join Date
    Oct 2009
    Posts
    3
    PS - do you know of a more secure way to do this? I'm relatively new to Javascript, so I am not familiar (yet) with security issues.

    Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles