Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbies Please Read: FAQlet

0 views
Skip to first unread message

er...@cc.gatech.edu

unread,
May 26, 1996, 3:00:00 AM5/26/96
to

From: er...@cc.gatech.edu (Erica L. Sadun)
Subject: Newbies Please Read: FAQlet
Date: 25 May 1996 18:25:09 -0400


-----------------------------------------------------------------------
T h e J a v a S c r i p t F A Q l e t
"The itty bitty sister of the real faq"
Contributions and clarifications to: er...@cc.gatech.edu
-----------------------------------------------------------------------

-----------------------------------------------------------------------
What is JavaScript
-----------------------------------------------------------------------

0.0 Q: "WHAT IS JAVASCRIPT?"

JavaScript is one of the new family of programming languages which
were
developed specifically for World Wide Web Pages. With JavaScript,
you can create interactive WebSites that really seem to come alive.
And here's the good part:
* You don't need a special account to write in JavaScript.
You include the programs directly in your HTML files.
* You don't need to use a compiler.
Your browser interprets JavaScript just like it interprets HTML
In fact, if you feel comfortable writing HTML, you'll feel
comfortable
writing JavaScript. It's really that easy. [ELS]

0.1 Q: "HOW CAN I USE JAVASCRIPT?"

Say you're running a business site. You could use JavaScript to help
fill
a shopping cart and keep track of a customer's order. Or you might
use
JavaScript to store a profile of your customer's preferences or
mailing
information so he doesn't have to fill out this information each time
he places an order.

If you're a hobbyest, you can use JavaScript to write games. You can
find
any number of sites on the World Wide Web already that have guessing
games
and memory games all written in JavaScript.[ELS]

0.2 Q: "HOW IS JAVASCRIPT DIFFERENT FROM JAVA?"

* Java is a full object-oriented compiled programming language
meant for programmers.

* JavaScript, in contrast, is a simple interpreted scripting
language meant for the rest of us.

* It's a much smaller language, It's a much simpler language.

* It's a language meant for creating small tight utilities
rather than large comprehensive applications.

* If you're comfortable with Basic, HyperCard, Forth or Logo, or
even just HTML, I think you'll have very little trouble
learning JavaScript.[ELS]

0.3 Q: "WHAT OTHER BROWSERS SUPPORT JAVASCRIPT?"

Microsoft Internet Explorer has announced support of JavaScript
but the current betas execute only trivial JavaScript code. [ELS]

-----------------------------------------------------------------------
Page Doesn't Work Right
-----------------------------------------------------------------------

1.0 Q: "MY PAGE DOESN'T LOAD CORRECTLY"
A: Add Height and Width tags to all your IMGs. [ELS]
A: Add width attributes to all your tables that contain JavaScript.
[Paul Andrews]
We can't specify the widths of tables, because a typical table
is
as wide as n input widgets, and we don't know how wide they are.
[David Zink]
A: This should be OK: <IMG SRC="myimg.gif" HEIGHT=100
WIDTH=50>
This may cause weird errors: <IMG SRC="myimg.gif"> [Brian Stoler]
A: For windows generated by JavaScript function calls, "Begin your
output with document.open() and end with document.close()"
[Matthew Glidden]

1.1 Q: "HOW CAN I MAKE THE CLICK FUNCTION WORK ON MY BUTTONS?"
A: You can't. Click is broken on most platforms. [ELS]

1.2 Q: "HOW CAN I AUTOMATICALLY UPDATE SELECTION LISTS TO A NEW VALUE?"
A: You can't. [ELS]

-----------------------------------------------------------------------
Scrolling Banners
-----------------------------------------------------------------------

2.0 Q: "I LOVE THOSE SCROLLING BANNERS. WHERE CAN I GET ONE?"
A: http://www.mindspring.com/~morrione [ELS]

2.1 Q: "I HATE THOSE SCROLLING BANNERS. HOW DO I TURN THEM OFF?"
A: http://www.mindspring.com/~webrx/devirus.html or turn
off JavaScript. [ELS]

-----------------------------------------------------------------------
Source Code Issues
-----------------------------------------------------------------------

3.0 Q: "HOW DO I HIDE JAVASCRIPT CODE FROM OLD BROWSERS?"
A: General Method 1:
<SCRIPT Language='JavaScript'><-- JavaScript Follows
...
<-- JavaScript Ends --></SCRIPT>

General Method 2:
<SCRIPT Language='JavaScript'><-- JavaScript Follows
...
//JavaScript Ends --></SCRIPT>

Hints:
* Replace i-- with i -= 1
* Replace x > y with y < x
* Declare var tmp = unescape('%3E') and add it to your
strings. e.g. document.write('</FONT'+tmp)
rather than document.write('</FONT>')
[ELS][Helped by Bill Dortch][Helped by Ronan Waide]

3.1 Q: "IS 'SRC =' (SOURCE INCLUSION FROM SECONDARY FILES) BROKEN?"
A: Yes. [ELS]

3.2 Q: "CAN I KEEP MY JAVASCRIPT CODE SECRET?"
A: No. Source code can not be kept secret. Your reader's browser
needs to see the source in order to execute it. If you need
code secrecy, consider using Java. [ELS]

-----------------------------------------------------------------------
JavaScript Functionality
-----------------------------------------------------------------------

4.0 Q: "HOW DO I PLAY SOUNDS WITH JAVASCRIPT?"
A: Set the location attribute to a sound URL. Be aware: the sound
will not play synchronously. Do not try to attach "click" sounds
to buttons. The click may be heard up to five minutes after the
button has been pressed.

self.location='foo.au' [ELS]

4.1 Q: "HOW DO I MAKE A LINK UPDATE TWO FRAMES?"
A: Use a function.

<SCRIPT language='javascript'>
function doit(){
parent.biffyframe.location='http://blah blah'
parent.spiffyframe.location='http://blah blah'
}
</SCRIPT>

<A HREF='javascript:doit()'>a link</a>

4.2 Q: "HOW DO I HANDLE SELECTION LISTS?"
A: Index of the selection: myIndex = aForm.SELNAME.selectedIndex
Text of the selection: myText =
aForm.SELNAME.options[myIndex].text
[ELS]

4.3 Q: "HOW DO I MAKE ANIMATED GIFS WITH JAVASCRIPT?"
A: An animated gif is NOT a computer program! It is simply the
combination
of different images combined into one gif. Compuserve released
this
format quite some time ago, but just recently it started
receiving
publicity. To make an animated gif, you will need to make a
series of
images portraying the animation you wish to show, then use a
utility,
such as Graphics Construction Set, and combine these into one.
Please
note the animation will currently show only on Netscape 2.0 or
higher.
[Jerome Blake]
A: See: http://member.aol.com/royalef/gifanim.htm [ELS]

4.4 Q: "HOW DO I CALL JAVA APPLET METHODS FROM JAVASCRIPT?"
A: Wait for Atlas beta public release 2 (3.0b3)

4.5 Q: "HOW DO I MAKE TWO WINDOWS TALK TO EACH OTHER"
A: Make sure to create a backwards link from the second window while
creating it.

e.g. myWin = window.open(blah blah)
myWin.mainWindow = self

and from the source in myWin
myWin.mainWindow.document.open()
myWin.mainWindow.document.write('blah blah')

[ELS]

4.6 Q: "HOW DO I DETECT PLUG-INS"
A: Search the text string returned by Navigator.plugins (Atlas)
[ELS]

4.7 Q: "I CAN SET WINDOW HEIGHT AND WIDTH. HOW DO I SET ITS LOCATION?"
A: You can't. [ELS]

4.8 Q: "HOW DO I AUTOSEND/CUSTOMIZE MAIL?"
A: You can't. Security reasons. Mail can only be sent by a
user's button press. You can not create mail
programmatically.[ELS]

4.9 Q: "HOW DO I RECOVER THE WINDOW SIZE OR LOCATION?"
A: You can't. [ELS]

-----------------------------------------------------------------------
Buttons and ImageMaps
-----------------------------------------------------------------------

5.0 Q: "HOW DO I COLOR BUTTONS?"
A: You cannot. [ELS]

5.1 Q: "HOW DO I USE ONMOUSEOVER WITH A BUTTON"
A: You cannot. [ELS]

5.2 Q: "HOW DO I USE THE UNDOCUMENTED IMAGE FORM ELEMENTS?"
A: Use "IMAGE" as the type. <INPUT TYPE="IMAGE" SRC="wherever">.
This form element does not support any events. [ELS]

5.3 Q: "HOW DO I RECOVER COORDINATES FROM IMAGE MAPS?"
A: The form must submit and the coordinates recovered from the
"search" property of the location.href. There is no way to
recover coordinates on the fly. [ELS]

-----------------------------------------------------------------------
Documentation
-----------------------------------------------------------------------
Netscape Docs:

http://home.netscape.com/comprod/products/navigator/version_2.0/script/
http://home.netscape.com/eng/mozilla/2.0/handbook/javascript/jsdoc.zip

Frames Docs:
http://home.netscape.com/assist/net_sites/frames.html

Cookie Docs:
http://www.netscape.com/newsref/std/cookie_spec.html

Tutorials:
http://www.webconn.com/java/javascript/intro/

[ELS]

-----------------------------------------------------------------------
Contributions by and information plundered from:
-----------------------------------------------------------------------
* Erica L. Sadun * Paul Andrews * Brian Stoler * Bill Dortch
* Matthew Glidden * John Lehmann * Ronan Waide * Larry W. Virden
* Lyndsey McCollam * Andrew Smith * David Zink

Last Revision 22 May 1996
--
=================================ERICA
SADUN==================================
"JavaScript Cookbook" forthcoming from Charles River Media. ISBN
1-886801-35-5
US & Canadian Orders: 1-800-382-8505 (9-5 EDT) Fax ordering:
703-689-0660
[Never Forget: http://www.wiesenthal.com/children/spaolo.htm]
=============================er...@cc.gatech.edu========================
======


Message-ID: <4o81c5$e...@cleon.cc.gatech.edu>
Organization: College of Computing, Georgia Tech
Path:
news.eunet.fi!EU.net!howland.reston.ans.net!swrinde!cssun.mathcs.emory.e
du!cc.gatech.edu!erica

0 new messages