Cut-and-Paste JavaScript Code

On most of my JavaScript sample pages, I show the exact code required to perform the script. If you like, you can just copy-and-paste that code right to your own PC. I strongly suggest that you first paste the code into a simple text editor, like Windows' Notepad, to remove any formatting put in by my HTML editors.

Here's an example of how you might go about copying and pasting a chunk of code from one of my pages to your PC using Windows 95 or 98.

  1. First, open Notepad (click the Windows Start button and choose Programs -> Accessories -> Notepad
  2. Get to the page that contains the code you want to copy, just using your web browser.
  3. Select the code that you want to copy, including the  <script> and </script> tags as in the example shown below (Figure 1). I realize you can't see detail in that figure. But the idea is that just the JavaScript code on the page is selected.

Figure 1: Chunk of code on one of my JavaScript sample pages is selected.

  1. Press Ctrl+C or choose Edit -> Copy from your browser's menu bar to copy the selected code to the Windows Clipboard.
  2. Bring Notepad back into view (click its Taskbar button if it's hidden).
  3. Right-click inside Notepad's window and choose Paste.

The code lands in Notepad as in the figure below (Figure 2). Again, I realize the picture is blurry. But I don't have an elegant way to reduce screenshot images without that blurriness.

Now, before you copy any code into one of your web pages, copy it out of Notepad. That is, choose Edit -> Select All from Notepad's menu bar, then press Ctrl+C. That'll get rid of any weird formatting codes from my HTML editors. Now you can paste the clipboard contents into any web page's document source.

Optionally, you can just save the code in Notepad to a text file by choosing File -> Save from Notepad's menu bar.

Figure 2: Code that was copied to the Clipboard is now in Notepad.


Top   JavaScript Examples   Coolnerds Home

 

Hit Counter
Hosted by www.Geocities.ws

1