logo_michael-thomas.jpg (3143 bytes)

Examples of JavaScript

This web page contains links to JavaScript examples.  Enjoy.

My Examples (by Michael Thomas)

  • Popup related examples:
    • Popup Blocker Check - Let's a person check to see if they have a popup blocker installed on their computer.
    • Popup Example - Example of creating a popup window.
  • Applet Check
    • Applet Check - check to see if your browser supports Applets and Applet scripting.
  • Environment (ex_environment.htm) - JavaScript to see what environment your user is using (brower, version, screen size, etc...)
  • Redirect - Example of using ( window.location.href = ) to redirect you to another page.
  • JavaScript & Music
  • Simulate Disabling the Browsers Back button.
    • <body onunload="javascript:history.go(1)"> - I've tested this one.
    • Other notes:
      • window.history.forward(1)
      • <script language="JavaScript">
  • Alert() JavaScript Function
  • Confirm() JavaScript Function
  • Scrolling Of Rows Within A Table - Example of rows that scroll under table headings.
  • Browser Window
    • Browser Window (open/close) (ex_window_openclose.htm)- Examples of opening and closing browser windows.  Some of the windows do not have toolbars.  Simple but neat!
    • ex_window_close.htm - JavaScript to close a browser window.  This link will create a new browser window, then you can click on the link to close the window.
    • ex_window.htm - JavaScript that experiments with the Window object.  Disabling the right mouse button (view source, print, etc...), removing toolbars, naming windows, creating new windows, etc...)
    • ex_window_onfocus.htm - Example of moving focus from one Web page to another using the onFocus property of the body tag.
    • ex_window_onblur.htm - Example of using the onBlur property of the body tag.
    • Window - hhwinclose - Example using the <object> hhwinclose (hhwinclose.Click()).  Closes a window without the users permission.
    • Body Tag- (onLoad & OnUnload) Example - example of using the onLoad and onUnload with the <body> tag.
    • Frame- Onload & Onunload Examples - examples of using onLoad and onUnload with frames (<frameset> tag).  
  • ex_obj_properties.htm - JavaScript that shows the properties in an object (DOM's).  Good code for debuging use.
  • History Object Examples - Example of using the History Object.
  • ex_htmlemail.htm - HTML Email example.
  • ex_htmlparm.htm - HTML parm examples (reading and passing the values) using "?" or "#".
  • ex_form.htm - JavaScript and accessing forms and their elements.
  • ex_form_layers.htm - JavaScript accessing forms in and out of layers (<div>).  IE vs Netscape problem.
  • ex_expcol_IENS.htm - Expand & Collapse Text (browsers: NS & IE) - (partially under construction)
  • ex_frameA_set.htm - An example of using JavaScript to store information about forms in another persistent frame and then later restoring the form's states.  Also, the bottom navigation frame will control the order that html files will be loaded in the middle frame.
  • ex_frameB_set.htm - An example of using JavaScript with frames to replace the _top with another web page.
  • ex_rollover.htm - An example of using JavaScript to display a different images when the mouse rolls over another image.  Also has examples of text links that change color using CSS (Cascading Style Sheets).
  • ex_metatag_expirecontent.htm - (Not Working at my site.  The http server must enable this option.) Expire HTML code so that it will not initially show when you view the source.
  • ex_print_noframe.htm - Use JavaScript to print from a hyperlink or button.
  • ex_print_frame_set.htm  - Use JavaScript to print different frames or all frames.
  • Print Formatting - Use JavaScript to show a print button on a screen, but when the screen is printed the bring button is removed.  Also, any other information can be treated that way.  (Works with IE.  Doesn't work with Netscape.)
  • ex_refresh.htm - Refresh a web page using JavaScript.
  • Cookies - Information and examples of using cookies.
  • onUnload IE vs NS - onUnload works differently between IE & Netscape.  See examples at this link.
  • setTimeout() Examples - Examples of using setTimeout().
  • Redirect to another Web page.  Notes for now, later an example.
    • Meta Tag:  <META HTTP-EQUIV="Refresh" CONTENT="10; URL=alternative.html"> - This meta tag will cause a new page to be loaded in 10 seconds.
    • <head>
      <SCRIPT LANGUAGE="JavaScript">
      var myURL = "http://www.yahoo.com";
      location = myURL;
  • Add Bookmark to Favorites
  • Add Bookmark To Favorites Ex #2

JavaScript Problems

  • Win 95 OS load browser script problem (ex_win95_ns_problem_local_load.html)
    • Win 95 (B) and Netscape problem when OS starts Netscape browser.  If you save this next web page to your local and execute it from Explorer you will find that the scripts will execute 2 times instead of once.  If you CTRL-R (reload) the page it operates fine.  I have not noticed the problem with Win 2000 or Win NT 4.0.  IE seems to work fine with Win95.
    • Java launching the default browser (Netscape) - OS starts Netscape browser 2 times.  I've seen this in the following OS's using Netscape 4.75: Win NT4.0 & Win 2000 (haven't tested others).  IE seems to work fine.
      Example JavaCode:
      SystemProcess spCommand = new SystemProcess();
      spCommand.runCommand ("ex_win95_ns_problem_local_load.html"); //Launch default browser to browse the html file.

JavaScript Notes

  • Characters (js_characters.htm) - Notes about JavaScript and Characters.
  • Operators (js_operators.htm) - List some of the Operators used in JavaScript (typeof, etc...).

Need to Finish (notes & work in progress)

  • Modal & Non-Modal dialog boxes.  A dialog box will display a popup box to your user.  If it is "modal", the user must deal with the dialog box before returning to the browser window.  If it is "non-modal", the user may return to the browser window.

 mailbox_hand.gif (3164 bytes)

home.jpg (2907 bytes)

FPCreated.gif (9864 bytes)

FPCreated.gif (1990 bytes)

Contact Me: Click Here   Search: Click Here  Home Page:  Free Java Certification Training by Michael Thomas