Java Scrip #1
Have an Alert box
with new line in it
Print special
character like copyright sign
Load an HTML page
depending on the browser type
Use COOKIE to count
the user access to a page
Make a switch to
another page after a delay
Change an image when
clicking on it
Check and Uncheck a
checkbox
Emulate the BACK
button
Have a simple
on-screen clock
Make sure that a
page is displayed in a Frame
Make sure that a
page is not displayed in a Frame
Send email without
CGI
Send email with
attachment
Instruct the browser
to bypass the Cache
Open a window with
no menu, toolbar or status
Open a page from a
FORM INPUT field
Compare Strings
Have an Alert box with new line in it
This tip is also good for inserting new line into a TextArea.
"\r\n" stands for carriage Return and New line. On Netscape, only the \n may
be necessary but with Explorer, you need both. To be compatible with both always use the
combination "\r\n".
Print
special character like copyright sign
To show in an alert box with accentued characters, use something like this :
|
Load an HTML page depending on the browser type
The browser version can be obtain with
browserVersion = parseInt(navigator.appVersion); |
Use
COOKIE to count the user access to a page
Make a switch to another page after a delay
Actually there is no Javascript for this trick, only HTML!
"content" is the delay in seconds. Here we will wait 5 seconds before jumping to the specified URL.
To auto-refresh (reload) a page after the delay, the HTML solution is still good. A JAVASCRIPT alternative would be :
Change an image when clicking on it
Check and Uncheck a checkbox
Emulate the BACK button
Make sure that a page is displayed in a Frame
note : replace "index.html" by your "frame-handler" page Make sure that a page is not displayed in a Frame
Send email without CGI
Works with Netscape. The important thing is to NAME all the INPUT. The
browser will prompt the user that an email is about to be sent.
To set the subject :
ACTION="mailto:[email protected]?subject=automatic_email" |
To send a Carbon Copy of the message to a second person, use the "cc" parameter :
While you can use a FORM to define the message body, it's also possible to define the body directly in the mailto: URL :
mailto:[email protected]?body=HelloWorld |
Send email with attachment
Netscape only
Instruct the browser to bypass the Cache
Open a window with no menu, toolbar or status
") } |
Open a page from a FORM INPUT field
Compare Strings
Case sensitive:
if (aString == anotherString) { alert("equals"); } |
Not case-sensitve:
if (aString.toUpperCase() == anotherString.toUpperCase()) { alert("equals"); } |
12/04/99