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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Writing data in files at client machine using javascript in chrome

    Hi,

    I want to write a file using javascript at client machine using chrome.
    Chrome doesnt allow activeX object. however there are add ons to counter the issue.
    The requirement is writing a file without using addon.
    Kindly suggest.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    JavaScript running in the browser does not have any commands for reading or writing files. JavaScript is a client-side language; modern browsers can read files on the server using an Ajax call, but otherwise JavaScript has no capability to read from, write to or delete any file (except a cookie).

    MSIE (only) can write to files ON THE USER'S COMPUTER (only), but only if the user marks your site as being a "safe" site and only if he/she agrees to let your page run an "unsafe for scripting" ActiveX control.


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    do you just need to save some file, or a file in a specific place?

    in a cross-browser fashion, javascript can only add files to your downloads folder.

    in chrome, you can actually drag a file from a special link to any folder.

    since you mentioned chrome, i wasn't sure if that's all you needed to support or not.

    anyway, look into <a> download and dnd download

    @pm: you have less than a month before i start calling you out on that because Chrome, FireFox and IE will all support forced downloads.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by rnd me View Post
    @pm: you have less than a month before i start calling you out on that because Chrome, FireFox and IE will all support forced downloads.

    Yes, but not existing versions of those browsers.
    There is no point in coding for IE10 (only) while plenty of people are still using IE9, IE8, IE7 and even IE6.

    You obviously revel in the very latest technology, but I live in the real world where lots of people are still several years behind the latest innovations.
    Last edited by Philip M; 03-07-2013 at 07:01 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    Quote Originally Posted by Philip M View Post
    Yes, but not existing versions of those browsers.
    There is no point in coding for IE10 (only) while plenty of people are still using IE9, IE8, IE7 and even IE6.

    You obviously revel in the very latest technology, but I live in the real world where lots of people are still several years behind the latest innovations.
    well, if 51% of browsers could force a download, one could say your orig answer was mostly wrong. As it stands, by statcounter, you're at least 95% wrong...

    you said yourself that old IE can already do this, and now, so can everyone else...
    it's like your arguments are "only old IE machines can do that" and "only new machines can do that", which doesn't make a whole heck of a lot of sense, does it?

    surely if most devices can do this, your warning text should be altered from the blanket denial you've been using since forever ago.

    otherwise, it seems like you are defining javascript capabilities based a small minority of users, not the vast majority of available clients.


    to me, the word "can't" implies the current state of affairs, whereas "counldn't" is probably a more accurate match for your overall message.
    Last edited by rnd me; 03-07-2013 at 07:40 PM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Decided to see how my "browser modernity" statistics stack up with yours, RndMe:

    page hits: 177029
    msie 5: 99 -- 0.05%
    msie 6: 1793 -- 1.01%
    msie 7: 2452 -- 1.39%
    msie 8: 5701 -- 3.22%
    msie 9: 8912 -- 5.03%
    msie 10: 810 -- 0.45%
    all phone/mobile: 28175 -- 15.92%

    So... phone/mobile usage (which is almost surely all HTML 5 or close to it) is more than all MSIE combined.

    Hmmm...

    (By the by, the total pagehits includes web crawlers--google, yahoo, bing, etc. At a first cut--without refining the data more--it looks like only 93,000 of the page hits were actually from browser usage. So the percentages shown can be roughly doubled to reflect browser-only usage. Sometime I'll refined the data more carefully, but not now.)
    Last edited by Old Pedant; 03-07-2013 at 09:20 PM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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