Things You'll Need:
- A web browser and an internet connection
-
Step 1
Before you begin, be aware that a lot of content from various websites is copyrighted, meaning you won't be able to outright copy a site's JavaScript legally. However, you can usually take a look at it and make modifications and adaptations to use on your own site.
-
Step 2
First, visit the page that has the JavaScript that you would like to view and copy.
-
Step 3
View the web page's source code. In Firefox, you can do this by typing Ctrl+U in Firefox. (That means you hold down the control button while typing the letter "U"). In Internet Explorer, you can usually right click on the page and then click "view source".
-
Step 4
Sometimes the JavaScript is kept on the page itself. So look in the source code for tags saying "script". The JavaScript will be found between these tags.
-
Step 5
While you may find the code inside the source of the page, most of the time JavaScript files are added to the website via "includes". For example:
type="text/javascript" src="/scripts/mycode.js"
The above line is part of an include for a JavaScript file.
To find this easily, you can just type "Ctrl+F" and then search for ".js". This will show you where on the page the JavaScript files, if any, are included. -
Step 6
Now look at the location bar of your web browser at the top of the window. You should see something like "www.mydomain.com", or "www.someorg.org". This is the web site's domain name.
-
Step 7
After the domain name, copy and paste the "/scripts/mycode.js" link that you got from the "src=" above.
For example type in "www.mydomain.com/scripts/mycode.js"
Then hit enter. The JavaScript file should display its contents in your web browser. -
Step 8
You can save the JavaScript file by selecting "File" and then "Save As" or by just highlighting all of the text and copying and pasting it into a text file.
-
Step 9
It's quite often the case that are 2 or 3 JavaScript files on one page and you may have to download all of them. It is possible that a function in one of the JavaScript files is calling a function in another file.
In other words, you may need to download all of the ".js" files in order to get something that you can work with.







