How to Run JavaScript in the Tag Line
JavaScript is used to add additional functions to a Web page. For example, JavaScript can change the appearance of the mouse cursor when a visitor is active on the page, create animated roll-overs or trigger pop-up windows. You can run a JavaScript function from within a HyperText Markup Language tag line. HTML tags add elements to a page, such as links or forms, and are enclosed in angle brackets, or chevrons. HTML tags use special attributes like "onmouseover" or "onclick" to call functions.
Instructions
-
-
1
Insert "<script type="text/javascript"></script>" in between the "<head></head>" tags at the top of the page.
-
2
Insert the following in between the "<script>" tags:
function functionName()
{ code } -
-
3
Replace "functionName" with the name of the JavaScript function. Replace "code" with the function code.
-
4
Insert "attribute="()"" into the desired tag line to run JavaScript. For example, to run a JavaScript mouseover function from the "<a>" tag, insert "<a href="http://www.mywebsite.com/link" onmouseover="functionName()">" into the page HTML.
-
1
Tips & Warnings
You can see the list of JavaScript event attributes on the W3Schools site.