FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type?

Discussion in 'Javascript' started by FAQ server, May 12, 2007.

  1. FAQ server

    FAQ server Guest

    -----------------------------------------------------------------------
    FAQ Topic - How do I prompt a "Save As" dialog for an
    accepted mime type?
    -----------------------------------------------------------------------

    It is not possible with client-side JavaScript.

    Some browsers accept the Content-Disposition header, but this
    must be added by the server. Taking the form:-
    ` Content-Disposition: attachment; filename=filename.ext `

    http://aspfaq.com/show.asp?id=2161

    http://support.microsoft.com/support/kb/articles/Q260/5/19.ASP


    ===
    Postings such as this are automatically sent once a day. Their
    goal is to answer repeated questions, and to offer the content to
    the community for continuous evaluation/improvement. The complete
    comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
    The FAQ workers are a group of volunteers.
    FAQ server, May 12, 2007
    #1
    1. Advertising

  2. FAQ server

    Evertjan. Guest

    FAQ server wrote on 12 mei 2007 in comp.lang.javascript:

    > -----------------------------------------------------------------------
    > FAQ Topic - How do I prompt a "Save As" dialog for an
    > accepted mime type?
    > -----------------------------------------------------------------------
    >
    > It is not possible with client-side JavaScript.


    Which is logical, my dear Watson Faq, as the below header line ASP-
    insertion is "executed" in the browser BEFORE any clientside code runs.

    From a clientside only webside point of view,
    a view held by many clientside javascript programmers out of necessity,
    the question realy is:

    Is there anything in a clickable anchor, that forces such user response?

    There is!

    <a href='x.html'
    onclick='alert("please rightclick, choose `save as...`");return false;'
    >download me</a>


    ==================

    > Some browsers accept the Content-Disposition header, but this
    > must be added by the server. Taking the form:-
    > ` Content-Disposition: attachment; filename=filename.ext `


    <script language='jscript' runat='server'> //ASP-enabled server needed
    Response.AddHeader('content-disposition','attachment;filename=x.html');
    </script>

    > http://aspfaq.com/show.asp?id=2161


    [shows only ASP-vbscript]

    >
    > http://support.microsoft.com/support/kb/articles/Q260/5/19.ASP



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., May 12, 2007
    #2
    1. Advertising

  3. FAQ server

    shimmyshack Guest

    On May 12, 9:07 am, "Evertjan." <> wrote:
    > FAQ server wrote on 12 mei 2007 in comp.lang.javascript:
    >
    > > -----------------------------------------------------------------------
    > > FAQ Topic - How do I prompt a "Save As" dialog for an
    > > accepted mime type?
    > > -----------------------------------------------------------------------

    >
    > > It is not possible with client-side JavaScript.

    >
    > Which is logical, my dear Watson Faq, as the below header line ASP-
    > insertion is "executed" in the browser BEFORE any clientside code runs.
    >
    > From a clientside only webside point of view,
    > a view held by many clientside javascript programmers out of necessity,
    > the question realy is:
    >
    > Is there anything in a clickable anchor, that forces such user response?
    >
    > There is!
    >
    > <a href='x.html'
    > onclick='alert("please rightclick, choose `save as...`");return false;'
    >
    > >download me</a>

    >
    > ==================
    >
    > > Some browsers accept the Content-Disposition header, but this
    > > must be added by the server. Taking the form:-
    > > ` Content-Disposition: attachment; filename=filename.ext `

    >
    > <script language='jscript' runat='server'> //ASP-enabled server needed
    > Response.AddHeader('content-disposition','attachment;filename=x.html');
    > </script>
    >
    > >http://aspfaq.com/show.asp?id=2161

    >
    > [shows only ASP-vbscript]
    >
    >
    >
    > >http://support.microsoft.com/support/kb/articles/Q260/5/19.ASP

    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)


    <html>
    <head></head>
    <body>
    <iframe frameborder="0" width="0" height="0" src="" id="file"
    name="file"></iframe>
    <a href="data:application/vnd.ms-excel;base64,MSwyLDMsNA=="
    target="file">click here</a>
    </body>
    </html>
    shimmyshack, May 12, 2007
    #3
  4. FAQ server

    -Lost Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    shimmyshack wrote:
    > <html>
    > <head></head>
    > <body>
    > <iframe frameborder="0" width="0" height="0" src="" id="file"
    > name="file"></iframe>
    > <a href="data:application/vnd.ms-excel;base64,MSwyLDMsNA=="
    > target="file">click here</a>
    > </body>
    > </html>


    I find it odd that only Opera gets it right.

    Isn't this type of thing useless for all MIME types that the browser can
    open natively?

    --
    -Lost
    Remove the extra words to reply by e-mail. Don't e-mail me. I am
    kidding. No I am not.
    -Lost, May 12, 2007
    #4
  5. FAQ server

    shimmyshack Guest

    On May 12, 12:13 pm, -Lost <> wrote:
    > shimmyshack wrote:
    > > <html>
    > > <head></head>
    > > <body>
    > > <iframe frameborder="0" width="0" height="0" src="" id="file"
    > > name="file"></iframe>
    > > <a href="data:application/vnd.ms-excel;base64,MSwyLDMsNA=="
    > > target="file">click here</a>
    > > </body>
    > > </html>

    >
    > I find it odd that only Opera gets it right.
    >
    > Isn't this type of thing useless for all MIME types that the browser can
    > open natively?
    >
    > --
    > -Lost
    > Remove the extra words to reply by e-mail. Don't e-mail me. I am
    > kidding. No I am not.


    yes you are right.
    but what if you dont set the correct mimetype for the file,
    I haven't pushed at the edges on this one.

    <html>
    <body>
    <iframe frameborder="0" width="100" height="100" src="" id="file"
    name="file"></iframe>
    <?php
    $data = file_get_contents( 'http://groups.google.com/groups/img/gicons/
    science_n_technology_42.gif' );
    #$mime = 'image/gif'; #true mimetype
    $mime = 'application/x-unknown'; #arbitrary one
    ?>
    <a href="data:data:<?php echo $mime; ?>;base64,<?php echo
    base64_encode($data);?>" target="file">click here</a>
    </body>
    </html>

    The filename is the tough part, it's argueable whether a "save as"
    dialog _is_ prompted for an accepted mime because we are setting an
    unacceptable mime, for data which after all doesnt have an intrisic
    mime. I just thought this was worth a mention, a curiosity for mozilla
    based browsers, one wonders if it's a feature that might be removed
    later - if it is never adopted by IE.
    shimmyshack, May 12, 2007
    #5
  6. FAQ server

    ASM Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    shimmyshack a écrit :
    >
    > <html>
    > <head></head>
    > <body>
    > <iframe frameborder="0" width="0" height="0" src="" id="file"
    > name="file"></iframe>
    > <a href="data:application/vnd.ms-excel;base64,MSwyLDMsNA=="
    > target="file">click here</a>
    > </body>
    > </html>


    Funny, on my Mac with FF in local, that opens Excel with in 1st cell
    '1,2,3,4'
    (after a dialog to 'open' or 'save' or 'cancel')
    and ... nothing comes in the iframe.

    the name of the sheat is : 5zfcwiy0-1.xls
    - from where this name comes ?
    - from where '1,2,3,4' comes ?

    Where to find some more informations about this
    href="data:application/vnd.ms-excel;base64,..." ?

    Can we use it with other applications !MS ?
    application/openoffice.org;
    application/another-application;

    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, May 12, 2007
    #6
  7. FAQ server

    shimmyshack Guest

    On May 12, 2:16 pm, ASM <>
    wrote:
    > shimmyshack a écrit :
    >
    >
    >
    > > <html>
    > > <head></head>
    > > <body>
    > > <iframe frameborder="0" width="0" height="0" src="" id="file"
    > > name="file"></iframe>
    > > <a href="data:application/vnd.ms-excel;base64,MSwyLDMsNA=="
    > > target="file">click here</a>
    > > </body>
    > > </html>

    >
    > Funny, on my Mac with FF in local, that opens Excel with in 1st cell
    > '1,2,3,4'
    > (after a dialog to 'open' or 'save' or 'cancel')
    > and ... nothing comes in the iframe.
    >
    > the name of the sheat is : 5zfcwiy0-1.xls
    > - from where this name comes ?
    > - from where '1,2,3,4' comes ?
    >
    > Where to find some more informations about this
    > href="data:application/vnd.ms-excel;base64,..." ?
    >
    > Can we use it with other applications !MS ?
    > application/openoffice.org;
    > application/another-application;
    >
    > --
    > Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    > Stephane Moriaux and his (less) old Mac already out of date


    i've seen it used in ajax apps a bit, for small images, not sure why,
    perhaps just because they could.

    its not M$ compaitible - they never implemented this.
    the name is randomly generated by your OS, and the source
    MSwyLDMsNA==
    is 1,2,3,4 base64 encoded
    here's a start:
    http://www.ietf.org/rfc/rfc2397.txt
    and you could use it with whatever application deals with the mimetype
    you specify in the source.

    cool huh, but limited in scope
    shimmyshack, May 12, 2007
    #7
  8. FAQ server

    ASM Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    shimmyshack a écrit :
    >
    > <html>
    > <body>
    > <iframe frameborder="0" width="100" height="100" src="" id="file"
    > name="file"></iframe>
    > <?php
    > $data = file_get_contents( 'http://groups.google.com/groups/img/gicons/
    > science_n_technology_42.gif' );


    How, with JS, could I get content of my image file ?
    (gif image on same domain)

    > #$mime = 'image/gif'; #true mimetype
    > $mime = 'application/x-unknown'; #arbitrary one
    > ?>
    > <a href="data:data:<?php echo $mime; ?>;base64,<?php echo
    > base64_encode($data);?>" target="file">click here</a>


    is it : href="data:data: ... "
    or : href="data: ... "
    ?


    > </body>
    > </html>
    >
    > The filename is the tough part, it's argueable whether a "save as"
    > dialog _is_ prompted for an accepted mime because we are setting an
    > unacceptable mime, for data which after all doesnt have an intrisic
    > mime. I just thought this was worth a mention, a curiosity for mozilla
    > based browsers, one wonders if it's a feature that might be removed
    > later - if it is never adopted by IE.


    Tried with FF followed code (*) :

    onclick="parent.myfile.location.href='data:image/gif;base64,'+
    encodeBase64(document.images[0].src); return false;"

    but the iframe tells :
    picture “data:image/gif;base64,blah”
    can't be dispayed because of errors.

    Think 'data' is the image's url (encoded in base 64)


    (*) encodeBase64() is a JS encoding function found here :
    <http://www.ioswebdesign.com/index.php/2006/12/06/>

    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, May 12, 2007
    #8
  9. FAQ server

    shimmyshack Guest

    On May 12, 2:52 pm, ASM <>
    wrote:
    > shimmyshack a écrit :
    >
    >
    >
    > > <html>
    > > <body>
    > > <iframe frameborder="0" width="100" height="100" src="" id="file"
    > > name="file"></iframe>
    > > <?php
    > > $data = file_get_contents( 'http://groups.google.com/groups/img/gicons/
    > > science_n_technology_42.gif' );

    >
    > How, with JS, could I get content of my image file ?
    > (gif image on same domain)
    >
    > > #$mime = 'image/gif'; #true mimetype
    > > $mime = 'application/x-unknown'; #arbitrary one
    > > ?>
    > > <a href="data:data:<?php echo $mime; ?>;base64,<?php echo
    > > base64_encode($data);?>" target="file">click here</a>

    >
    > is it : href="data:data: ... "
    > or : href="data: ... "
    > ?
    >
    > > </body>
    > > </html>

    >
    > > The filename is the tough part, it's argueable whether a "save as"
    > > dialog _is_ prompted for an accepted mime because we are setting an
    > > unacceptable mime, for data which after all doesnt have an intrisic
    > > mime. I just thought this was worth a mention, a curiosity for mozilla
    > > based browsers, one wonders if it's a feature that might be removed
    > > later - if it is never adopted by IE.

    >
    > Tried with FF followed code (*) :
    >
    > onclick="parent.myfile.location.href='data:image/gif;base64,'+
    > encodeBase64(document.images[0].src); return false;"
    >
    > but the iframe tells :
    > picture "data:image/gif;base64,blah"
    > can't be dispayed because of errors.
    >
    > Think 'data' is the image's url (encoded in base 64)
    >
    > (*) encodeBase64() is a JS encoding function found here :
    > <http://www.ioswebdesign.com/index.php/2006/12/06/>
    >
    > --
    > Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    > Stephane Moriaux and his (less) old Mac already out of date


    I think it's the binary data.
    What you would do is have an XHR call return base64 encoded data from
    a serverside script, the string would then not have errors. Depending
    on the browser, there might be a limit to the size of the image, this
    method would be best for very small images.
    shimmyshack, May 12, 2007
    #9
  10. FAQ server

    -Lost Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    ASM wrote:
    > Where to find some more informations about this
    > href="data:application/vnd.ms-excel;base64,..." ?


    http://en.wikipedia.org/wiki/Data:_URI_scheme

    --
    -Lost
    Remove the extra words to reply by e-mail. Don't e-mail me. I am
    kidding. No I am not.
    -Lost, May 12, 2007
    #10
  11. FAQ server

    -Lost Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an accepted

    shimmyshack wrote:
    > On May 12, 2:52 pm, ASM <>
    > wrote:
    >> shimmyshack a écrit :
    >>
    >>
    >>
    >>> <html>
    >>> <body>
    >>> <iframe frameborder="0" width="100" height="100" src="" id="file"
    >>> name="file"></iframe>
    >>> <?php
    >>> $data = file_get_contents( 'http://groups.google.com/groups/img/gicons/
    >>> science_n_technology_42.gif' );

    >> How, with JS, could I get content of my image file ?
    >> (gif image on same domain)
    >>
    >>> #$mime = 'image/gif'; #true mimetype
    >>> $mime = 'application/x-unknown'; #arbitrary one
    >>> ?>
    >>> <a href="data:data:<?php echo $mime; ?>;base64,<?php echo
    >>> base64_encode($data);?>" target="file">click here</a>

    >> is it : href="data:data: ... "
    >> or : href="data: ... "
    >> ?
    >>
    >>> </body>
    >>> </html>
    >>> The filename is the tough part, it's argueable whether a "save as"
    >>> dialog _is_ prompted for an accepted mime because we are setting an
    >>> unacceptable mime, for data which after all doesnt have an intrisic
    >>> mime. I just thought this was worth a mention, a curiosity for mozilla
    >>> based browsers, one wonders if it's a feature that might be removed
    >>> later - if it is never adopted by IE.

    >> Tried with FF followed code (*) :
    >>
    >> onclick="parent.myfile.location.href='data:image/gif;base64,'+
    >> encodeBase64(document.images[0].src); return false;"
    >>
    >> but the iframe tells :
    >> picture "data:image/gif;base64,blah"
    >> can't be dispayed because of errors.
    >>
    >> Think 'data' is the image's url (encoded in base 64)
    >>
    >> (*) encodeBase64() is a JS encoding function found here :
    >> <http://www.ioswebdesign.com/index.php/2006/12/06/>
    >>
    >> --
    >> Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    >> Stephane Moriaux and his (less) old Mac already out of date

    >
    > I think it's the binary data.
    > What you would do is have an XHR call return base64 encoded data from
    > a serverside script, the string would then not have errors. Depending
    > on the browser, there might be a limit to the size of the image, this
    > method would be best for very small images.


    Since we are a tad off topic anyway.

    Here is code I use:

    // PHP
    $temp = 'image_name.x';
    $temp_h = fopen($temp, 'rb');
    $contents = fread($temp_h, filesize($temp));
    fclose($temp_h);
    $encoded = base64_encode($contents);
    print '<img src="data:image/png;base64,' . $encoded . '" />';

    You can see more at that Data URI article from Wikipedia.

    Oh, and Internet Explorer 6 does not play Data URIs. I have no clue
    about version 7.

    --
    -Lost
    Remove the extra words to reply by e-mail. Don't e-mail me. I am
    kidding. No I am not.
    -Lost, May 12, 2007
    #11
  12. FAQ server

    ASM Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    shimmyshack a écrit :
    > On May 12, 2:52 pm, ASM <>
    > wrote:
    >> Think 'data' is the image's url (encoded in base 64)



    > I think it's the binary data.
    > What you would do is have an XHR call return base64 encoded data from
    > a serverside script, the string would then not have errors.


    I would prefer to do everything in JS.

    > there might be a limit to the size of the image, this
    > method would be best for very small images.


    A small gif in pure html href="data: ..." :
    http://stephane.moriaux.perso.orange.fr/truc/favicon.gif.html

    Hope that works with IE ?

    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, May 12, 2007
    #12
  13. FAQ server

    ASM Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an accepted

    -Lost a écrit :
    >
    > Oh, and Internet Explorer 6 does not play Data URIs. I have no clue
    > about version 7.


    Oh ! it seems my IE(Mac) doesn't more :-(



    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, May 12, 2007
    #13
  14. FAQ server

    -Lost Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    ASM wrote:
    > shimmyshack a écrit :
    >> On May 12, 2:52 pm, ASM <>
    >> wrote:
    >>> Think 'data' is the image's url (encoded in base 64)

    >
    >
    >> I think it's the binary data.
    >> What you would do is have an XHR call return base64 encoded data from
    >> a serverside script, the string would then not have errors.

    >
    > I would prefer to do everything in JS.


    My friend, I seriously doubt this will happen. Even though I have seen
    some neat image creation methods in JavaScript, I doubt very much binary
    interaction can go on. I would love to be proved wrong on this one though.

    >> there might be a limit to the size of the image, this
    >> method would be best for very small images.

    >
    > A small gif in pure html href="data: ..." :
    > http://stephane.moriaux.perso.orange.fr/truc/favicon.gif.html
    >
    > Hope that works with IE ?


    Nope, not in Internet Explorer 6 on Windows XP SP2.

    Try this one in a browser that reads it:

    <img
    src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbgAAAAsCAYAAAAXSq1SAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEw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3AT9uYHrfodbgTcb+JGldYJLmKPaUhi3maF6cz+j7Zpbm0F9ZCFbmkxNOZ53sKU1w3jIPoeG/LbJotbzEtr8zZYOHekbHCwievPyWOv4H/ZlGg76fvf2YZ0IfB73akMyKLvWrhmEm9ecFiHLjeb4SmG4ZTdG+eywI/VvOLkUN18eV+ez7PrzcFMLSfrJt33967ACbWk8bhFkSVHaCOt8tuCW/67Drf6ZhVsiWohnabxcNodbNfUa9f8rQfBN8Q9ahzbV8rcbabh4YC2NVz55I3iPq63svZYyOcWOn/ads5yGmwSfo/GmwSh5vRRY3FxwbZGUbhx5StHrMqLfxp6FTgrJGMWxuBe9Lgaet+zAbju+IhCd9bey/cuR54REBFFtaQnhr6G70kbQz5jBX5BQl1nVBylki9uO4tpsHHuL87xBttmgpJD+NlD4DTdzLaIgoc0Pwa3aW2L92K00XrQRZII9Vy1ubmkmDd+uf7a11c3W4a4i/L2KxcpeG0jlec59nw0UxtogrZgszxPx4uGIQeabJs9Ya1/brH3VAt8roKconR9tfmIPbiHSMtyGfWLY4GVm/9ttABwWGb+AW5RTVayk
    ev5bjD7WCLsi1JaEEOUi1Rxcc3yDQ68qUvpncDlgvRezedJLKhDio0vrZijTcRYVVQPz1ISaNdXUloQQGdMcI7h2qhahtiSEaIkOLqdqEWpLQohSaY4pyq3E+w9WhVBbEuKjwQ7cqkwhhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEM2Z/wO4B+RS04XfkAAAAABJRU5ErkJggg=="
    />

    (I hope all this comes across, I am not entirely sure how to clip this
    at a reasonable length.)

    --
    -Lost
    Remove the extra words to reply by e-mail. Don't e-mail me. I am
    kidding. No I am not.
    -Lost, May 12, 2007
    #14
  15. FAQ server

    shimmyshack Guest

    On May 12, 4:54 pm, -Lost <> wrote:
    > ASM wrote:
    > > shimmyshack a écrit :
    > >> On May 12, 2:52 pm, ASM <>
    > >> wrote:
    > >>> Think 'data' is the image's url (encoded in base 64)

    >
    > >> I think it's the binary data.
    > >> What you would do is have an XHR call return base64 encoded data from
    > >> a serverside script, the string would then not have errors.

    >
    > > I would prefer to do everything in JS.

    >
    > My friend, I seriously doubt this will happen. Even though I have seen
    > some neat image creation methods in JavaScript, I doubt very much binary
    > interaction can go on. I would love to be proved wrong on this one though.
    >
    > >> there might be a limit to the size of the image, this
    > >> method would be best for very small images.

    >
    > > A small gif in pure html href="data: ..." :
    > >http://stephane.moriaux.perso.orange.fr/truc/favicon.gif.html

    >
    > > Hope that works with IE ?

    >
    > Nope, not in Internet Explorer 6 on Windows XP SP2.
    >
    > Try this one in a browser that reads it:
    >
    > <img
    > src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbgAAAAsCAYAAAAXSq1SAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wUMDzEDFdGnygAAACl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggVGhlIEdJTVAsIGJ5IE1pY2hhZWykgeE7AAALg0lEQVR42u2de7BVVR3HP+fyMJSXyktApSQ0qWGCJiSy1MwHOuUrhjKZJhgrbEQZIlOHkXAK05JemoMpSiaJCgEhAmFXAUEREQqvCkogD0NJQYiHePpj/fbcfffd5+zH2eeee67fz8ydwz5n771++7fWb/3W77fW2oAQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQIoRWUoEQQogq5GygB/CmVCGEEKIlsQdYV+yEGulICCFEFdIB2J+FgxsI3A7UAv8AFtvni8ATwIUh11wD3JbRg3QBZgILrew88EyVVMIwYDYwB3gf2F7i/bLUa7lII2NP4OfACuA54J/Av4GVwMgMZesC3GdtaZG1pYXqKxrUW1Pa20nA68CDEec9DtS1MH1PCuj42QrLc4zJ9BjwV2AL8CfghBLvOwp41fq/vRnb4H9K7QxmWwO8Cmgf+D0HnA8cAboGfqszwctBHni5Cht0Fjopp14r9ZwjgJ1mCG0D7etkoG8ZZc0Da+XbitZbOe2t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lgvRezedJLKhDio0vrZijTcRYVVQPz1ISaNdXUloQQGdMcI7h2qhahtiSEaIkOLqdqEWpLQohSaY4pyq3E+w9WhVBbEuKjwQ7cqkwhhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEM2Z/wO4B+RS04XfkAAAAABJRU5ErkJggg=="
    > />
    >
    > (I hope all this comes across, I am not entirely sure how to clip this
    > at a reasonable length.)
    >
    > --
    > -Lost
    > Remove the extra words to reply by e-mail. Don't e-mail me. I am
    > kidding. No I am not.


    tee hee! it does i am afriad. but hey parallels doesnt suck, (if it
    updated without a hitch it would be nice)
    shimmyshack, May 12, 2007
    #15
  16. FAQ server

    ASM Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    -Lost a écrit :
    > ASM wrote:
    >>
    >> I would prefer to do everything in JS.

    >
    > My friend, I seriously doubt this will happen. Even though I have seen
    > some neat image creation methods in JavaScript, I doubt very much binary
    > interaction can go on. I would love to be proved wrong on this one though.


    OK.

    I've played with this data:type-mine :
    http://perso.orange.fr/stephane.moriaux/truc/html_to_xls.shtml
    tested successfully in FF,
    Opera has a secutity or sthg to abort,
    iCab wants to download the data ...
    Safari donwloaded an Excel file, this file opens correctly in Excel.

    Don't know if that could be very usefull ... :-/

    > Try this one in a browser that reads it:


    TOO COOL ! ! !
    works fine with my FF 2, Safari 1.3, Opera 9, iCab 3,
    and *even with my old NC 4.5* ! ! !

    No french translation with mouseover ? :)

    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, May 12, 2007
    #16
  17. FAQ server

    -Lost Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    ASM wrote:
    > -Lost a écrit :
    >> ASM wrote:
    >>>
    >>> I would prefer to do everything in JS.

    >>
    >> My friend, I seriously doubt this will happen. Even though I have
    >> seen some neat image creation methods in JavaScript, I doubt very much
    >> binary interaction can go on. I would love to be proved wrong on this
    >> one though.

    >
    > OK.
    >
    > I've played with this data:type-mine :
    > http://perso.orange.fr/stephane.moriaux/truc/html_to_xls.shtml
    > tested successfully in FF,
    > Opera has a secutity or sthg to abort,
    > iCab wants to download the data ...
    > Safari donwloaded an Excel file, this file opens correctly in Excel.
    >
    > Don't know if that could be very usefull ... :-/


    In Opera 9.10 on Windows XP SP2, all I get is your error about it being
    Internet Explorer.

    You test this way:

    if(document.getElementById && !document.all)
    // your error

    But Opera supports document.getElementById and document.all.

    Was that on purpose?

    >> Try this one in a browser that reads it:

    >
    > TOO COOL ! ! !
    > works fine with my FF 2, Safari 1.3, Opera 9, iCab 3,
    > and *even with my old NC 4.5* ! ! !
    >
    > No french translation with mouseover ? :)


    Sorry, no! I don't know how to say "it sucks" in French.

    if (Mac.Internet_Explorer == 'merdeux') { alert('Oui!'); }

    --
    -Lost
    Remove the extra words to reply by e-mail. Don't e-mail me. I am
    kidding. No I am not.
    -Lost, May 12, 2007
    #17
  18. FAQ server

    ASM Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    -Lost a écrit :
    > ASM wrote:
    >> -Lost a écrit :
    >>> ASM wrote:

    >>
    >> I've played with this data:type-mine :
    >> http://perso.orange.fr/stephane.moriaux/truc/html_to_xls.shtml


    > In Opera 9.10 on Windows XP SP2, all I get is your error about it being
    > Internet Explorer.
    >
    > You test this way:
    >
    > if(document.getElementById && !document.all)
    > // your error
    >
    > But Opera supports document.getElementById and document.all.


    I know.

    > Was that on purpose?


    because Opera did cry about I don't know what
    and because anyway I don't like Opera
    hop! outside !
    but you can see here what he does with my script :
    http://perso.orange.fr/stephane.moriaux/truc/html_to_xls_op

    Tiens ?
    is was not simple to fix, but this time that works with my Opera 9
    (easiest if Excel is opened first)

    > if (Mac.Internet_Explorer == 'merdeux') { alert('Oui!'); }


    :)

    if(any.Internet_Explorer) { alert('garbage');


    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    ASM, May 12, 2007
    #18
  19. FAQ server

    ASM Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    Randy Webb a écrit :
    > -Lost said the following on 5/12/2007 4:32 PM:
    >>
    >> You test this way:
    >>
    >> if(document.getElementById && !document.all)
    >> // your error
    >>
    >> But Opera supports document.getElementById and document.all.
    >>
    >> Was that on purpose?

    >
    > Doubtfully. It probably comes from the belief that the only browser that
    > supports both is IE and that is wrong.


    Not at all ! I know Opera as iCab accept document.all

    > A better test, in that code would be if(!IE)


    Yes I did test it (1st line in demo's JS) but my Opera played me a "tour
    de cochon" so I left it.


    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    ASM, May 12, 2007
    #19
  20. FAQ server

    -Lost Guest

    Re: FAQ Topic - How do I prompt a "Save As" dialog for an acceptedmime type?

    ASM wrote:
    > -Lost a écrit :
    >> ASM wrote:
    >>> -Lost a écrit :
    >>>> ASM wrote:
    >>>
    >>> I've played with this data:type-mine :
    >>> http://perso.orange.fr/stephane.moriaux/truc/html_to_xls.shtml

    >
    >> In Opera 9.10 on Windows XP SP2, all I get is your error about it
    >> being Internet Explorer.
    >>
    >> You test this way:
    >>
    >> if(document.getElementById && !document.all)
    >> // your error
    >>
    >> But Opera supports document.getElementById and document.all.

    >
    > I know.
    >
    >> Was that on purpose?

    >
    > because Opera did cry about I don't know what
    > and because anyway I don't like Opera
    > hop! outside !
    > but you can see here what he does with my script :
    > http://perso.orange.fr/stephane.moriaux/truc/html_to_xls_op
    >
    > Tiens ?
    > is was not simple to fix, but this time that works with my Opera 9
    > (easiest if Excel is opened first)


    I don't even have Excel on this machine and it works just fine
    (OpenOffice.org).

    >> if (Mac.Internet_Explorer == 'merdeux') { alert('Oui!'); }

    >
    > :)
    >
    > if(any.Internet_Explorer) { alert('garbage');


    I would agree with that, except Randy would beat me (maybe Jim too?).
    And quite frankly, I don't have any good answer as to why I think all
    Internet Explorer related stuff is crud. ;)

    --
    -Lost
    Remove the extra words to reply by e-mail. Don't e-mail me. I am
    kidding. No I am not.
    -Lost, May 13, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CJ
    Replies:
    1
    Views:
    1,553
    Andrew Thompson
    Oct 29, 2004
  2. dave

    prompt "Save as" dialog for image

    dave, Nov 19, 2004, in forum: ASP General
    Replies:
    8
    Views:
    217
  3. mizi

    Download dialog for known MIME type

    mizi, Oct 30, 2005, in forum: ASP General
    Replies:
    0
    Views:
    154
  4. Jan Arickx
    Replies:
    0
    Views:
    186
    Jan Arickx
    Aug 25, 2003
  5. FAQ server
    Replies:
    1
    Views:
    199
    Dr J R Stockton
    Oct 16, 2008
Loading...

Share This Page