javascript tutorials

Javascript Code Snippets

Here is a handy collection of some very simple, commonly used JavaScript code snippets:

Links -
  • Blank JavaScript link
    (Better than #, because the browser doesn't jump back to the top.)
  • Close window
  • <a href="javascript:window.close();">Close Window</a>
  • Print window
  • <a href='javascript:;' onClick='window.print();return false'>Print this page</a>

Images -

  • Preload images
  • <script type="text/javascript">
    if (document.images)
    {
    img1 = new Image();
    img2 = new Image();

    img1.src = "imageName1.gif";
    img2.src = "imageName2.gif"

    }
    </script>

Custom Search
Tutorials JavaScript Resouces
Some developers offer ready made
scripts that can be modified to work
in your website. Some of these
scripts are free and some require a
small fee, but they are well worth it: