useful javascript, open window, back button, break frames

javascript examples

This is not a complete javascript reference but rather a guide to javascripts that any one with a website may find useful.
Probably the most frequent javascript question is how do i open a window using javascript? the truth is that you dont need a javascript tutorial to open a window, in fact you dont need to use javascript, because simple html can be used to open a new browser window. All that is required to open a new window is to add target="_blank" to links, here's an example
<A HREF="index.html" target="_blank">home</A>

javascript popup window tool
use this online tool to create a javascript popup window and generate the html source code click here

javascripts on this page

   javascript : reload page
this 'javascript reload page' link is useful because it allows users to reload the page, it is especially useful on servers where images frequently fail to load. this javascript link can be placed anywhere in the body of the document

if images are missing from this page reload page

   javascript : break frames
this javascript will automatically break a frame, place it in the head of your html document and you will never have to worry about someone loading your page into a frame, the javascript will 'smash' out of the frame.
This is a harsh way to break out of a frame and another option is to allow users to break out of the frame 'softly' when they click on one of your links more info

   javascript : browser redirect
use this javascript to redirect users according to the browser they are using.
If you have you optimized your site for a certain browser use this script in the head of your html document.
Many websites are optimized for a certain browser, but they don't tell the visitor.
This leads to visitors not being able to view parts of the site (or the whole site)
This javascript allows you to make a page for each browser so that all users can view your page.
Remember to change 'explorer.html' and 'netscape.html' to the names of the pages you wish to redirect to.

   javascript : auto redirect
this javascript is similar to the one above and redirects users regardless of the browser they are using.
Place the javascript in the head of your html document and remember to change 'index.html' to the name of page you wish to redirect to

   javascript : back button
this javascript back button code uses a form button that when clicked on sends the user back to the last webpage veiwed
*Please note, this javascript back button should not be relied upon alone and a link to your home page should also be included where ever this javascript back button is used, the reason, if a user arrives at one of your pages from a search engine and clicks on the javascript back button they will simply be sent back to the search engine.
so be kind and do yourself a favour include a link to your homepage where ever the back button is used

try it

a text link could also be used
<A HREF="javascript:history.go(-1)">back</A>

  javascript : alert
the 'javascript alert' is probably the easiest (and the most annoying) javascript event to code.

heres an example
<a href="javascript:alert('your message here')">alert example</A>

find out more about javascript alerts

  javascript : stop errors
one javascript that's worth having on all of your webpages is the stop errors function, this is a two part code, the function should be placed in the head of the html document and it is activated by the 'onload' command in the body tag