LanguagesJavaScriptHeadline Script

Headline Script content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.


Today we wrap this up. Let them click, I say!


The Script’s Effects

Here’s the Code


Now that all the values are set, we can trigger the function that makes the link occur. In the IE version of the script, the onClick is within the text box. In the Navigator version, the onClick is in a button. Either way, both trigger a function called goTo(inlocation).

Now, you’ll notice that inside the parantheses of the function is the variable we just set, “inlocation”. That variable represents the URL of the headline currently displaying in the visible text box.

Now, let’s take a look at the function goTo(). You’ll find it up high in the script just below the the two functions chngNext() and chngPrev()

function goTo(newURL) 

What the author is doing here is passing a specific value to the fuction. The first line of the function has the variable “newURL” inside its instance. When the user clicks the button or the text box to go to the headline, the variable “inlocate” is passed to this function.

When the function runs, the value of “inlocate” is transferred and is now given the variable name newURL. By doing it that way, the “inlocate” value can now be used within the goTo() function. It just has to be called “newURL” inside the function.

The only line in the function forces a link to be made:


The location the browser will link to is “newURL”, which is the value passed to the function as “inlocate” which was the value created in the headMack() function.

It’s a long way to go – but effective.

Well, there you go. Another script broken down. Next week we’ll get into a password script and some JavaScript tricks to hiding the password in the code.

Next Time: New Script: Passwords

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories