Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-07-2013, 09:47 AM   PM User | #1
tejo93
New to the CF scene

 
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
tejo93 is an unknown quantity at this point
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.
tejo93 is offline   Reply With Quote
Old 03-07-2013, 10:27 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
Philip M is online now   Reply With Quote
Old 03-07-2013, 05:33 PM   PM User | #3
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,469
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
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 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Old 03-07-2013, 06:58 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
__________________

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.

Last edited by Philip M; 03-07-2013 at 07:01 PM..
Philip M is online now   Reply With Quote
Old 03-07-2013, 07:25 PM   PM User | #5
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,469
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
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.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%

Last edited by rnd me; 03-07-2013 at 07:40 PM..
rnd me is offline   Reply With Quote
Old 03-07-2013, 09:16 PM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.)
__________________
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.

Last edited by Old Pedant; 03-07-2013 at 09:20 PM..
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:20 AM.


Advertisement
Log in to turn off these ads.