Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving the document after adding content dynamically

    Hi All,

    I am facing a certain problem when I try to add a content to a page dynamically and then save the page.
    I add a content dynamically to the page on a mouse click and then after the content appears in the screen, I try to save the HTML file from the browser. When I open the saved HTML file, I am not able to see the dynamically added text. This happens only in IE.

    This is the code that I use.
    "document.body.insertAdjacentHTML("beforeEnd", "<div id='idCanvas'> Sample Text </div>");"

    This code successfully adds the new text to the page. But, when I try to save the page from "File -> Save As" and then open the saved file, I am not able to view that text. I need to get that text in the saved document as well.

    I also tried using

    var oDiv = document.createElement("div");
    oDiv.setAttribute("id","idCanvas");
    var oText = document.createTextNode("SampleText")
    oDiv.appendChild(oText);
    document.body.appendChild(oDiv);


    Even with this I am facing the same problem. In Firefox, I am able to get the dynamically added text but not in IE. Can anyone help me with this?

    Thanks in Advance,
    rsarun

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    To the best of my knowledge, it's not possible to save generated html through File->Save As in IE. You can get various IE developer tools that will let you see the generated HTML and then you could save that but I think that's the best you'll get. Sorry

  • #3
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I also thought that would be the case. I just wanted to confirm that. Anyways, thnx for your help.

    Regards,
    rsarun

  • #4
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I also thought that would be the case. I just wanted to confirm that. Anyways, thnx for your help.

    Regards,
    rsarun

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,640
    Thanks
    0
    Thanked 649 Times in 639 Posts
    See http://javascript.about.com/library/blsource.htm for a script you can add to your favorites menu that will display the current (modified) source of the page in a separate window from which you can then save it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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