|
No Problem. To borrow scripts from other web pages, you only need to know about four (4) things. Number 1: - The Script Itself For instance a common script might look like this:
The stuff between the tags composes the script itself. It can be located just about anywhere in the HTML source, but it is most commonly found in the head (between the <HEAD> and </HEAD> tags>. We'll talk more about what all of this stuff does later, but for now, just realize that this whole thing composes the script itself. This stuff would all need to be copied into your web page. It would be best if you place it in the same section of your page that you found it in the other page (i.e. i f it was in the head of the page you are borrowing from, put it in the head of your page. to see a page with some JavaScript. View the source and see if you can locate the script. If you can (and you can) copy it and come back and paste i t into your document. Number 2: - The Event See the part that says function scrollit(seed)? It looks like this:
Do you see the red words that say scrollit(seed). This is the function name. How do I know this? Because it follows the word function.
Click here to see that JavaScript page. View the source and see if you can locate the event that starts the script. If you can (and you can) copy it and come back and paste it into your document in the same place that you found it. Number 3: - The Related Objects The script that we are currently borrowing scrolls a message across that status bar at the bottom of the browser window. In the case of the script that we are working with right now, no objects need to be created for the script to run. But, let's suppose that instead of scrolling words across the status bar, the words were being scrolled across a wide text box (which can be done). Click here to see what I mean. In this case, the HTML in your page would have to provide a text box for the text to be scrolled in. You must reproduce the object that is used in the original page exactly in your HTML, including the name, size, or other attributes of the particular obj ect. So, if the original page uses a text box defined as follows: <form name="announce"><input type="text" name="display" size=55></form> . Failure to reproduce this in your source exactly could cause the script to run incorrectly or not at all. Go try to reproduce this last example in your document. Be sure to reproduce ALL necessary components. Number 4: - Copyright Infringement So, all this time you thought you could just go out and take advantage of those fools that learned how to program JavaScript by borrowing their scripts and using them yourself. WRONG!! You should never just take a script without asking. True, no one will probably ever know, and even if they did, they probably wouldn't say anything. But, it is always a good idea - not to mention polite - to ask permission to use a script from the script owner. Often, information regarding allowable usage, persons to contact in order to request permission, or other copyright-type information is included in the script itself (often in the head) and is commented out. There, I've relieved my conscience, and won't feel like I didn't warn you if you decide to pirate someone's script. Customizing the Script You've learned about all of the things you need to borrow a script "as-is" from someone else's web site. But, you may be wondering, "This script I borrowed is great, but it has a really bad joke on it. How do I cus tomize it?" Customizing is pretty simple. You know that message that you don't want? More than likely it is just typed into the JavaScript code. Look through the script itself until you find the text that you want to change (in the example script in your CodeRunner, we made it real easy to find the scrolling text value) and replace it with whatever you want to use as your scrolling message. Cool huh? Save your work. See you at the Next learning lab... |