homepage Welcome to WebmasterWorld Guest from 54.237.98.229
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
File API: reader vs. event.target
Rain_Lover



 
Msg#: 4672756 posted 6:01 pm on May 20, 2014 (gmt 0)

I have studied many articles and posts to learn about File API and still don't understand why almost all of them use
event.target instead of reader. Here are three examples:

  1. File API [w3.org]
  2. Using files from web applications | MDN [developer.mozilla.org]
  3. Working with files in JavaScript, Part 2: FileReader | NCZOnline [nczonline.net]


The last reference even recommends using
event.target:

The FileReader instance is available inside of the event handler via event.target and itís recommended to use that instead of referencing the reader variable directly.


But why is it recommended and widely used? What's wrong with using
reader or simpler this instead: DEMO [jsfiddle.net].

I know
this and event.target can be different, but in this case they both refer to the FileReader object and result is in fact a FileReader property [developer.mozilla.org] -- just like onload, which is a FileReader event [developer.mozilla.org].

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved