SHARE
Facebook X Pinterest WhatsApp

HTML Goodies: Script Tip: Week 72

Written By
thumbnail
Joe Burns
Joe Burns
Jan 4, 2005

 

Bonjour…

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



Here’s the Effect

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)
{

self.location.href=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:


self.location.href=newURL;

     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 Week: New Script: Passwords



     Do YOU have a Script Tip you’d like to share? How about suggesting a Script Tip to write about? I’d love to hear it. Write me at:
jburns@htmlgoodies.com.

Learn to write your own JavaScripts with the

Recommended for you...

The Revolutionary ES6 Rest and Spread Operators
Rob Gravelle
Aug 23, 2022
Ahead of Time (AOT) Compilation in Angular
Tariq Siddiqui
Aug 16, 2022
Converting a JavaScript Object to a String
Rob Gravelle
Aug 14, 2022
Understanding Primitive Type Coercion in JavaScript
Rob Gravelle
Jul 28, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.