Dynamically created pages are not saved in IExplorer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • The Pritchard

    Dynamically created pages are not saved in IExplorer

    I want the user to be able to save the information displayed on a
    dynamically created page.

    When I write a script like the following:

    <SCRIPT>
    winNew = window.open("", "test");
    winNew.document .writeln("Hello World!");
    winNew.document .close();
    winNew.focus();
    </SCRIPT>

    I can view it in IExplorer and if I view code I only see the "Hello World"
    part.
    But when I try to save it, I get the parent code (as I have typed above).
    In Netscape navigator I get the "Hello World", which is what I want.

    Do I need to change a setting in IExplorer?

    Or does IExplorer need different JavaScript code for this to work.

    I must use IExplorer.

    Dave


  • Thomas 'PointedEars' Lahn

    #2
    Re: Dynamically created pages are not saved in IExplorer

    The Pritchard wrote:
    [color=blue]
    > I want the user to be able to save the information displayed on a
    > dynamically created page.
    >
    > When I write a script like the following:
    >
    > <SCRIPT>
    > winNew = window.open("", "test");
    > winNew.document .writeln("Hello World!");
    > winNew.document .close();
    > winNew.focus();
    > </SCRIPT>[/color]

    This should read

    <script type="text/javascript>
    var winNew = window.open("", "test"), d;
    if (winNew && (d = winNew.document ))
    d.open("text/html");
    d.write(
    ['<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict"',
    ' "http://www.w3.org/TR/html4/strict.dtd">',
    '<html>',
    ' <head>',
    ' <title>foo<\/title>',
    ' <\/head>',
    ' <body>',
    ' <p>Hello World!<\/p>',
    ' <\/body>',
    '<\/html>'
    ].join("\n"));
    d.close();

    if (winNew.focus)
    {
    winNew.focus();
    }
    </script>
    [color=blue]
    > [...]
    > I can view it in IExplorer and if I view code I only see the "Hello World"
    > part.
    > But when I try to save it, I get the parent code (as I have typed above).
    > [...]
    > Do I need to change a setting in IExplorer?
    >
    > Or does IExplorer need different JavaScript code for this to work.[/color]

    No, you don't. Provided that it does not work with dynamically
    written Valid HTML as well (see above), it is simply borken.
    [color=blue]
    > I must use IExplorer.[/color]

    If you need to use buggy software, you need to build the document
    server-side (as it is unlikely that this will get fixed by M$;
    but that's the only reliable way doing it anyway) or ask the user
    to use View Source and Save (in the menu of the Notepad window that
    pops up by default).


    PointedEars

    Comment

    • The Pritchard

      #3
      Re: Dynamically created pages are not saved in IExplorer

      Thank you for your help.
      I tried the code you suggested and get the same result.
      I have never worked on the server-side.
      But I will look into that avenue.
      It seems a bit much to ask the user to view the code and save it but that
      will have to do for now.
      It helps to know it is not the code.

      Dave

      "Thomas 'PointedEars' Lahn" <PointedEars@nu rfuerspam.de> wrote in message
      news:40B95653.5 000202@PointedE ars.de...[color=blue]
      > The Pritchard wrote:
      >[color=green]
      > > I want the user to be able to save the information displayed on a
      > > dynamically created page.
      > >
      > > When I write a script like the following:
      > >
      > > <SCRIPT>
      > > winNew = window.open("", "test");
      > > winNew.document .writeln("Hello World!");
      > > winNew.document .close();
      > > winNew.focus();
      > > </SCRIPT>[/color]
      >
      > This should read
      >
      > <script type="text/javascript>
      > var winNew = window.open("", "test"), d;
      > if (winNew && (d = winNew.document ))
      > d.open("text/html");
      > d.write(
      > ['<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict"',
      > ' "http://www.w3.org/TR/html4/strict.dtd">',
      > '<html>',
      > ' <head>',
      > ' <title>foo<\/title>',
      > ' <\/head>',
      > ' <body>',
      > ' <p>Hello World!<\/p>',
      > ' <\/body>',
      > '<\/html>'
      > ].join("\n"));
      > d.close();
      >
      > if (winNew.focus)
      > {
      > winNew.focus();
      > }
      > </script>
      >[color=green]
      > > [...]
      > > I can view it in IExplorer and if I view code I only see the "Hello[/color][/color]
      World"[color=blue][color=green]
      > > part.
      > > But when I try to save it, I get the parent code (as I have typed[/color][/color]
      above).[color=blue][color=green]
      > > [...]
      > > Do I need to change a setting in IExplorer?
      > >
      > > Or does IExplorer need different JavaScript code for this to work.[/color]
      >
      > No, you don't. Provided that it does not work with dynamically
      > written Valid HTML as well (see above), it is simply borken.
      >[color=green]
      > > I must use IExplorer.[/color]
      >
      > If you need to use buggy software, you need to build the document
      > server-side (as it is unlikely that this will get fixed by M$;
      > but that's the only reliable way doing it anyway) or ask the user
      > to use View Source and Save (in the menu of the Notepad window that
      > pops up by default).
      >
      >
      > PointedEars[/color]


      Comment

      • Grant Wagner

        #4
        Re: Dynamically created pages are not saved in IExplorer

        The Pritchard wrote:
        [color=blue]
        > I want the user to be able to save the information displayed on a
        > dynamically created page.
        >
        > When I write a script like the following:
        >
        > <SCRIPT>
        > winNew = window.open("", "test");
        > winNew.document .writeln("Hello World!");
        > winNew.document .close();
        > winNew.focus();
        > </SCRIPT>
        >
        > I can view it in IExplorer and if I view code I only see the "Hello World"
        > part.
        > But when I try to save it, I get the parent code (as I have typed above).
        > In Netscape navigator I get the "Hello World", which is what I want.
        >
        > Do I need to change a setting in IExplorer?
        >
        > Or does IExplorer need different JavaScript code for this to work.
        >
        > I must use IExplorer.
        >
        > Dave[/color]

        When you do File -> Save As... in Internet Explorer, choose "Web Page, HTML
        only" rather then "Web Page, complete". If you File -> Save As... the result
        of a document.write( ) to a new window in Internet Explorer as "Web Page,
        complete", it does indeed insert a couple of headers, as well as the tags you
        left out, in addition to the source of the script that produced the new
        window.

        <META http-equiv=Content-Type content="text/html; charset=unicode ">
        <META content="MSHTML 6.00.2800.1400" name=GENERATOR> </HEAD>
        <BODY>
        <SCRIPT>
        winNew = window.open("", "test");
        winNew.document .writeln("Hello World!");
        winNew.document .close();
        winNew.focus();
        </SCRIPT>
        </BODY></HTML>

        This is unusual, but not entirely incorrect behaviour. To obtain a "complete"
        Web Page, Internet Explorer would need all the code that led up to the
        resulting window. I wonder what it would do with more complex situations
        (opened windows that wrote content that opened a window that wrote content
        that opened a window).

        --
        | Grant Wagner <gwagner@agrico reunited.com>

        * Client-side Javascript and Netscape 4 DOM Reference available at:
        *


        * Internet Explorer DOM Reference available at:
        *
        Learn with interactive lessons and technical documentation, earn professional development hours and certifications, and connect with the community.


        * Netscape 6/7 DOM Reference available at:
        * http://www.mozilla.org/docs/dom/domref/
        * Tips for upgrading JavaScript for Netscape 7 / Mozilla
        * http://www.mozilla.org/docs/web-deve...upgrade_2.html


        Comment

        Working...