From - Sat Jun 14 23:05:12 1997
Path: world1.bellatlantic.net!out2.nntp.cais.net!news2.cais.com!in1.nntp.cais.net!pumpkin.pangea.ca!www.nntp.primenet.com!nntp.primenet.com!news.mathworks.com!news1.best.com!nntp2.ba.best.com!not-for-mail
From: Danny Goodman <dannyg@dannyg.com>
Newsgroups: comp.lang.javascript
Subject: JavaScript Mini-FAQ (22May97)
Date: Thu, 05 Jun 1997 19:59:15 -0700
Organization: BookBoy
Lines: 160
Message-ID: <33977CE2.5EEA@dannyg.com>
Reply-To: dannyg@dannyg.com
NNTP-Posting-Host: dgoodman.vip.best.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0 (Macintosh; I; 68K)

JavaScript Mini-FAQ                                 (Updated 22May1997)*
------------------------------------------------------------------------
This FAQ covers the language through JavaScript 1.1, the version
deployed in Netscape Navigator 3.0x.  The focus here is on client-side 
JavaScript.
------------------------------------------------------------------------
Q. Where is the online documentation for JavaScript?
A. Current JavaScript docs (for Netscape Navigator) are available at:
<http://home.netscape.com/eng/mozilla/3.0/handbook/javascript/index.html>
   Documentation for Microsoft's implementation (called JScript) is at:
   <http://www.microsoft.com/JScript/us/techinfo/jsdocs.htm>

Q. Where is the official bug list for JavaScript?
A. Netscape publishes 'known bugs' in its online Navigator Release Notes
   (pull down the Help menu), but this list is not complete. To my
   knowledge, no definitive list exists online.

Q. Can JavaScript:
   - read or write random text files on the local disk or on the server?
   - invoke automatic printing of the current document?
   - control browser e-mail, news reader, or bookmark windows and menus?
   - access or modify browser preferences settings?
   - capture a visitor's e-mail address or IP address?
   - quietly send me an e-mail when a visitor loads my page?
   - launch client processes (e.g.,Unix sendmail,Win apps,Mac scripts)?
   - capture individual keystrokes?
   - change a document's background .gif after the page has loaded?
   - change the current browser window size, location, or options?
   - get rid of that dumb "JavaScript Alert:" line in alert dialogs?
A. No. Many of these items will be possible in Communicator/Navigator
   4.0 with the aid of "signed JavaScript". Stay tuned.

Q. Why won't my script work under MS Internet Explorer 3 for the Mac?
A. JScript has just become available for MSIE/Mac in the first beta
   release of IE 3.0.1. While I haven't put it through its paces
   thoroughly yet, the language and object model support appear to be
   the same as the Windows version (roughly equivalent to JavaScript 
   in Netscape Navigator 2.0x). It still needs work on the script error
   user interface. MSIE 3.0.1b runs on Mac 68K and PPC. You can 
   download it at:
      <http://www.microsoft.com/msdownload/ieplatform/iemac.htm>

Q. Why won't my Navigator 3.0x script run under MSIE 3 for Windows 95?
A. Most language features and objects that are new in Navigator 3.0 are
   not supported in MSIE 3.0.  Here's the quick list of items _not_ yet
   available in MSIE 3:

   UNSUPPORTED OBJECTS        
   -------------------
   Image  -- this means no onMouseOver swappable images in MSIE 3
   Area   -- no onMouseOvers
   Applet
   FileUpload
   Array  -- hard-wired (JS1.0) arrays OK; no true 'length' property
   MimeType
   Plugin

   UNSUPPORTED PROPERTIES/METHODS/EVENT HANDLERS OF SUPPORTED OBJECTS
   ------------------------------------------------------------------
   Window
      onerror  closed  blur()  focus()  scroll()  onBlur=   onFocus=
   Location
      reload()  replace()
   Document
      applets[]  domain  embeds[]  images[]  URL
   Link
      onMouseOut=
   Form
      reset()  onReset=
   (All Form Elements)
      type
   Navigator
      mimeTypes[]  plugins[]  javaEnabled()
   String
      prototype  split()

   *One more item: the <SCRIPT SRC="xxx.js"> facility for loading 
   external JavaScript library files is not available in IE3.0 
   (or Navigator 2.0x).

Q. How can I e-mail forms?
A. The most reliable way is to use straight HTML via a Submit style
   button. Set the ACTION of the <FORM> to a mailto: URL and the ENCTYPE
   attribute to "text/plain". For security reasons, the form.submit()  
   method does not submit a form whose ACTION is a mailto: URL.
   Microsoft Internet Explorer 3.0 does not e-mail forms of any kind.

Q. How do I script a visit counter?
A. At best, a client-side script can show the visitor how many times he
   or she has been to the site (storing the count in a local cookie). A
   count of total hits to the server requires a server-side CGI program.
   I have an article on cookies in the "View Source" archive (URL
below).

Q. Why is my script not working inside a table?
A. There is a long-standing bug with JavaScript and tables. Do not place
   <SCRIPT> tags inside <TD> tags. Instead, start the <SCRIPT> tag
   before the <TD> tag, and document.write() the <TD> tag through the
   </TD> tag. I go one step further, and document.write() the entire 
   table, interlacing script statements where needed.

Q. After window.open(), how do I access objects and scripts in the other
   window?
A. First, be sure to assign an 'opener' property to the new window if
   you are using a version of JS that doesn't do it automatically (Nav
   3.0x  and MSIE 3.0x do it automatically). The following script should 
   be a part of _every_ new window creation:

      var newWind = window.open("xxx","xxx","xxx")  // u fill in blanks
      if (newWind.opener == null) {  // for Nav 2.0x
         newWind.opener = self  // this creates and sets a new property
      }

   To access items in the new window from the original window, the 
   'newWind' variable must not be damaged (by unloading), because it
   contains the only reference to the other window you can use (the
   name you assign as the second parameter of open() is not valid
   for scripted window references; only for TARGET attributes).
   To access a form element property in the new window, use:

       newWind.document.formName.elementName.property

   From the new window, the 'opener' property is a reference to the
   original window (or frame, if the window.open() call was made
   from a frame). To reference a form element in the original window:

       opener.document.formName.elementName.property

   Finally, if the new window was opened from one frame in the main 
   browser window, and a script in the new window needs access to 
   another frame in the main browser window, use:

       opener.parent.otherFrameName.document.formName. ...

Q. How do I use JavaScript to password-protect my Web site?
A. There are any number of schemes (I've used some myself). Most of them
   fail to deflect the knowledgeable JavaScript programmer, because no
   matter how you encode the correct password (e.g., bit shifting), both
   the encoding algorithms and the result have to be in the script --
   whose source code is easily accessible.  If you're only interested in
   keeping out casual visitors, this method may suffice.

   A more secure way is to set the password to be the name or pathname
   of the HTML file on your site that is the 'true' starting page.  Set
   the location to the value entered into the field (unfortunately, you
   cannot extract the value property of a password object in Navigator 
   2.0x). Entry of a bogus password yields an 'invalid URL' error.

   If the protected pages need additional security (e.g., an infidel has
   managed to get the complete URL), you might also consider setting a
   temporary cookie on the password page; then test for the existence
   of that cookie upon entry to every protected page, and throw the 
   infidel back to the password page.
------------------------------------------------------------------------
Danny Goodman                          http://www.dannyg.com/javascript/
"JavaScript Bible, 2nd Ed." (IDG Books)               ISBN 0-7645-3022-4
------------------------------------------------------------------------
Latest "View Source" article.."Getting Ready for the JS 1.2 Event Model"
http://developer.netscape.com/news/viewsource/  (Also check the Archive)
------------------------------------------------------------------------
