activating the Save As command by JS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Dale

    activating the Save As command by JS

    Dear all,

    Is there any way to activate the Save As command from Javascript. I
    would like to have a "Save as" button on a page which has been
    dynamically created (client side using document.writel n) so that the
    user can save a copy.
    I am working towards cross browser compatibility so any help for any
    browser would be good.

    I know I could put up a bit of text telling the user what the shortcut
    key is but thats not as pretty.

    I am also aware that JS does not allow writing to the hard-disk (quite
    right too) but hopefully there is a way to do what I'm asking.

    Cheers,

    Martin

  • Michael Winter

    #2
    Re: activating the Save As command by JS

    On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
    <mdale9zz@landr over.zzcom/no_zz> wrote:
    [color=blue]
    > Dear all,
    >
    > Is there any way to activate the Save As command from Javascript. I
    > would like to have a "Save as" button on a page which has been
    > dynamically created (client side using document.writel n) so that the
    > user can save a copy.
    > I am working towards cross browser compatibility so any help for any
    > browser would be good.
    >
    > I know I could put up a bit of text telling the user what the shortcut
    > key is but thats not as pretty.
    >
    > I am also aware that JS does not allow writing to the hard-disk (quite
    > right too) but hopefully there is a way to do what I'm asking.[/color]

    Sorry, but there isn't. Furthermore, indicating the shortcut isn't very
    cross-browser compatible.

    Whilst most browsers will use similar shortcuts and menu layouts to make
    life easier for users, you can't guarantee success. Particularly as Opera
    users, like me (and others in this group), can redefine shortcuts at will.
    You best bet would be to point the user towards their menubar.

    By the way, I'm not sure whether saving a generated page will save the
    original source code or the resulting output. That too, might depend on
    the browser.

    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    • Sandman

      #3
      Re: activating the Save As command by JS

      In article <opr3mds0rn5vkl cq@news-text.blueyonder .co.uk>,
      Michael Winter <M.Winter@bluey onder.co.invali d> wrote:
      [color=blue]
      > On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
      > <mdale9zz@landr over.zzcom/no_zz> wrote:
      >[color=green]
      > > Dear all,
      > >
      > > Is there any way to activate the Save As command from Javascript. I
      > > would like to have a "Save as" button on a page which has been
      > > dynamically created (client side using document.writel n) so that the
      > > user can save a copy.
      > > I am working towards cross browser compatibility so any help for any
      > > browser would be good.
      > >
      > > I know I could put up a bit of text telling the user what the shortcut
      > > key is but thats not as pretty.
      > >
      > > I am also aware that JS does not allow writing to the hard-disk (quite
      > > right too) but hopefully there is a way to do what I'm asking.[/color]
      >
      > Sorry, but there isn't. Furthermore, indicating the shortcut isn't very
      > cross-browser compatible.
      >
      > Whilst most browsers will use similar shortcuts and menu layouts to make
      > life easier for users, you can't guarantee success. Particularly as Opera
      > users, like me (and others in this group), can redefine shortcuts at will.
      > You best bet would be to point the user towards their menubar.
      >
      > By the way, I'm not sure whether saving a generated page will save the
      > original source code or the resulting output. That too, might depend on
      > the browser.[/color]

      No, a browser will never be able to read the source code of a
      dynamically created page such as PHP or ASP.

      It would have to be dynamically created by the browser if the browser
      should have access to the code.

      Comment

      • Michael Winter

        #4
        Re: activating the Save As command by JS

        On Thu, 19 Feb 2004 16:16:27 +0100, Sandman <mr@sandman.net > wrote:
        [color=blue]
        > In article <opr3mds0rn5vkl cq@news-text.blueyonder .co.uk>,
        > Michael Winter <M.Winter@bluey onder.co.invali d> wrote:
        >[color=green]
        >> On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
        >> <mdale9zz@landr over.zzcom/no_zz> wrote:
        >>[color=darkred]
        >>> [...] a page which has been dynamically created (client side using
        >>> document.writel n) [...][/color][/color][/color]

        [snip]
        [color=blue][color=green]
        >> By the way, I'm not sure whether saving a generated page will save the
        >> original source code or the resulting output. That too, might depend on
        >> the browser.[/color]
        >
        > No, a browser will never be able to read the source code of a
        > dynamically created page such as PHP or ASP.[/color]

        Ermm, both I and the OP were referring to generation through JavaScript. I
        am well aware that browsers don't receive server-side code, only the
        output of it.

        Mike

        --
        Michael Winter
        M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

        Comment

        • Randy Webb

          #5
          Re: activating the Save As command by JS

          Sandman wrote:
          [color=blue]
          > In article <opr3mds0rn5vkl cq@news-text.blueyonder .co.uk>,
          > Michael Winter <M.Winter@bluey onder.co.invali d> wrote:
          >
          >[color=green]
          >>On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
          >><mdale9zz@lan drover.zzcom/no_zz> wrote:
          >>By the way, I'm not sure whether saving a generated page will save the
          >>original source code or the resulting output. That too, might depend on
          >>the browser.[/color]
          >
          >
          > No, a browser will never be able to read the source code of a
          > dynamically created page such as PHP or ASP.
          >
          > It would have to be dynamically created by the browser if the browser
          > should have access to the code.[/color]

          I think he is referring to JS-modified pages. And typically what you get
          is the original page.
          Example:

          Page is loaded, you change the innerHTML property of the body tag, and
          reload some new data, do a File>Save As and then open the saved page,
          you will get the original page.

          If you use a document.write, after the page loads, to "regenerate " a new
          page, and then File>Save As, you get the generated code.


          --
          Randy
          Chance Favors The Prepared Mind
          comp.lang.javas cript FAQ - http://jibbering.com/faq/

          Comment

          • Sandman

            #6
            Re: activating the Save As command by JS

            In article <opr3mi9knq5vkl cq@news-text.blueyonder .co.uk>,
            Michael Winter <M.Winter@bluey onder.co.invali d> wrote:
            [color=blue][color=green][color=darkred]
            > >> By the way, I'm not sure whether saving a generated page will save the
            > >> original source code or the resulting output. That too, might depend on
            > >> the browser.[/color]
            > >
            > > No, a browser will never be able to read the source code of a
            > > dynamically created page such as PHP or ASP.[/color]
            >
            > Ermm, both I and the OP were referring to generation through JavaScript. I
            > am well aware that browsers don't receive server-side code, only the
            > output of it.[/color]

            Then I apologize. My mistake. :)

            --
            Sandman[.net]

            Comment

            • Martin Dale

              #7
              Re: activating the Save As command by JS

              Randy Webb wrote:[color=blue]
              > Sandman wrote:
              >[color=green]
              >> In article <opr3mds0rn5vkl cq@news-text.blueyonder .co.uk>,
              >> Michael Winter <M.Winter@bluey onder.co.invali d> wrote:
              >>
              >>[color=darkred]
              >>> On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
              >>> <mdale9zz@landr over.zzcom/no_zz> wrote:
              >>> By the way, I'm not sure whether saving a generated page will save
              >>> the original source code or the resulting output. That too, might
              >>> depend on the browser.[/color]
              >>
              >>
              >>
              >> No, a browser will never be able to read the source code of a
              >> dynamically created page such as PHP or ASP.
              >>
              >> It would have to be dynamically created by the browser if the browser
              >> should have access to the code.[/color]
              >
              >
              > I think he is referring to JS-modified pages. And typically what you get
              > is the original page.
              > Example:
              >
              > Page is loaded, you change the innerHTML property of the body tag, and
              > reload some new data, do a File>Save As and then open the saved page,
              > you will get the original page.
              >
              > If you use a document.write, after the page loads, to "regenerate " a new
              > page, and then File>Save As, you get the generated code.
              >
              >[/color]
              What I actually meant was that in page 1 I open a new window
              new_win = open();
              then write stuff into that page (based on selections made in page 1)
              using document.writel n statements (I use writeln to write the
              <html><head> etc too).
              When you view the source of this generated page it is just standard HTML
              which you can save away to reload another day.

              Martin

              Comment

              • Andy_p

                #8
                Re: activating the Save As command by JS


                Martin Dale wrote:[color=blue]
                > *Dear all,
                >
                > Is there any way to activate the Save As command from Javascript. I
                > would like to have a "Save as" button on a page which has been
                > dynamically created (client side using document.writel n) so that the
                > user can save a copy.
                > I am working towards cross browser compatibility so any help for any
                > browser would be good.
                >
                > I know I could put up a bit of text telling the user what th
                > shortcut
                > key is but thats not as pretty.
                >
                > I am also aware that JS does not allow writing to the hard-dis
                > (quite
                > right too) but hopefully there is a way to do what I'm asking.
                >
                > Cheers,
                >
                > Martin *[/color]

                Try this for IE:
                document.execCo mmand("SaveAs", true);

                --


                ----
                Andy_

                Comment

                • Richard Cornford

                  #9
                  Re: activating the Save As command by JS

                  "Andy_p" <Andy_p.11xqws@ mail.forum4desi gners.com> wrote in message
                  news:Andy_p.11x qws@mail.forum4 designers.com.. .[color=blue]
                  >
                  > Martin Dale wrote:[color=green]
                  > > *Dear all,[/color][/color]
                  [color=blue]
                  > Andy_p[/color]

                  If you are trying to respond to someone on Usenet it would be a good
                  idea to use posting software that builds a References header for your
                  message in accordance with RFC 1036 -"Standard for Interchange of USENET
                  Messages" (1987). Which means going somewhere other than
                  forum4designes. com.

                  Richard.


                  Comment

                  • Thomas 'PointedEars' Lahn

                    #10
                    Re: activating the Save As command by JS

                    Richard Cornford wrote:
                    [color=blue]
                    > "Andy_p" <Andy_p.11xqws@ mail.forum4desi gners.com> wrote in message
                    > news:Andy_p.11x qws@mail.forum4 designers.com.. .[/color]

                    Please shorten your attribution since that makes
                    threads with your postings easier legible:
                    <http://www.netmeister. org/news/learn2quote1.ht ml#ss1.1>
                    [color=blue]
                    > If you are trying to respond to someone on Usenet it would be a good
                    > idea to use posting software that builds a References header for your
                    > message in accordance with RFC 1036 -"Standard for Interchange of USENET
                    > Messages" (1987). Which means going somewhere other than
                    > forum4designes. com.[/color]

                    The References header of his posting is OK.


                    PointedEars

                    Comment

                    • Richard Cornford

                      #11
                      Re: activating the Save As command by JS

                      Thomas 'PointedEars' Lahn wrote:
                      <snip>[color=blue]
                      > The References header of his posting is OK.[/color]

                      Yes I know. I think I hit the wrong message when I activated the view
                      source opting on my newsreader and confused myself by expecting a
                      forum4designers post to be wrong when they may actually have fixed the
                      References aspect of their software. (Which may just leave the
                      undesirable prefixing of "Re: " to the subject header of original posts
                      as the only obvious error remaining).

                      Richard.


                      Comment

                      Working...