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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2005
    Location
    Monterrey, Mexico
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question When saving dynamically generated documents, the parent document is the one saved.

    Hi there

    I am developing some tools for my department and I require some DHTML in them. The problem here is that when I create a document dinamically, i want my users to be able to save their dinamically generated documents, and this is not working neither on IE nor Mozilla (need the script to work on both browsers). If I click on the Save Page As option on the File Menu, the -parent- window document is the one that gets saved. But, if you view the source of the new document, you get the right content, and you can save the new content from here (-Save Page As- option from the -File- menu). Any idea around why this is happening and how to solve this problem? (Another variable in this issue is that I am using Spanish, but using the right charset solves it.)

    Here is an example code of this behavior (i tried to write one as small as possible):

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title></title>
    <style type="text/css" id="style">
    .red {color:#FF0000}
    </style>
    <script language="JavaScript" type="text/javascript">
    function render()
    {
    var doc = "<html lang=\"es\" xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"es\">\n<head>\n";
    doc += "<META HTTP-EQUIV=\"Content-Language\" Content=\"es\" />\n";
    doc += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"; //charset=iso-8859-1
    doc += "<title></title>\n<style type=\"text/css\">\n";
    doc += document.getElementById("style").innerHTML;
    doc += "</style>\n<body id='body'>\n" + escape(document.getElementById("body").innerHTML);
    doc += "</body>\n</html>";
    var win = window.open("","","width=800;height=600,menubar,scrollbars,resizable");
    win.document.write(unescape(doc));
    win.document.close();
    parent.win = self;
    }
    </script>
    </head>

    <body id="body">
    <span onclick="this.innerHTML='SOMETHING JUST CHANGED!'">This text is in spanish</span>: ¡Visita México este año <a href="#" onclick="render()" title="Click me!">2005</a>!
    </body>
    </html>

    If you click on the text "This text is in spanish", you get new text. Try it. Now, click on "2005". You´ll get the new document. Now save it and open it in a browser: -you got the parent document-. Now view the source of the new document: -you get the new content-.

    I´ve been researching about this issue for a pair of weeks now with no success at all.

    Help?

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    The browser is saving the document from the server/cache. It will not save the changes made to it. You most likely need a server side code to create the page and have them download it.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Feb 2005
    Location
    Monterrey, Mexico
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Thanks Eric, but...

    ... i do not have the option of a server-side generated document, reason for which i am working entirely on a client-side solution.

    Are you saying that there is -no way- to save client-side generated documents as the browser will always save which ever document is in the server/cache (that is, the parent document)?


  •  

    Posting Permissions

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