Accessing the Disk


Here's a quick one that I'm putting right after cookies because it involves accessing information from the user 's hard disk. It's just a small topic that doesn't really fit anywhere else in the book, but it's a nice trick to know.

By setting the ACTION attribute to a file: URL in the Internet Explorer, you can get access to the user's hard disk in Windows, displaying the file structure. Here's an example:

(Listing 23-05.html on the web site)
 <HTML>      <HEAD>          <TITLE>Accessing the Disk</TITLE>      </HEAD>      <BODY>          <H1>Accessing the Disk</H1>  <FORM ACTION="file:///c/">   <INPUT TYPE="submit" VALUE="See C: Drive">   </FORM>  </BODY>  </HTML> 

You can see the results in Figure 23.6, where the file structure of the C: drive is displayed.

Figure 23.6. Accessing the disk.

graphics/23fig06.gif

It's time to turn to the other topic we're going to cover in this chapter: creating custom objects. As mentioned at the beginning of this chapter, some programmers say that JavaScript isn't object-oriented so much as object-based. And that's also true when you want to create your own objectsyou can put them together object by object. You don't create the OOP classes that genuine OOP languages such as Java or C++ use. Instead, you add can add properties one at a time to objects just by assigning values to them. You also can add methods the same wayby assigning a method to an objectas we'll see.

That's not to say that you can't add a new property or method to a whole set of objects at the same timeusing prototypes , you can, as we'll see here. However, you still don't start with classes and then create objects as you do in true OOP languages; you work with objects from the very beginning.

Let's take a look at this now, starting by creating custom objects and giving them properties.



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net