It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Two functions in one external script .. How?

Two functions in one external script .. How?

Postby MattoThePotatto on Mon Jul 14, 2008 8:30 am

Hey. I've been trying to make a website with a 'description' of the link when you hover over the links. That function works fine. I've also tried to add a bookmark. That function works fine.. But when I have them in the same .js file, neither works.

Can someone please look at my code and see if I'm doing anything wrong? Thanks a lot, and thanks in advance.


<html>
<head>
<title>|Page Title|</title>
<link rel="shortcut icon" href="icon.ico" />
<script src="scripts.js">
</script>
<style type="text/css">
body
{
margin: 0px;
}
td#navigation a
{
display: block;
border-top: solid 1px #000000;
border-bottom: solid 1px #000000;
line-height: 120%;
text-align: left;
margin-top: 2px;
margin-bottom: 2px;
text-decoration: none;
color: 000000;
}
td#navigation a:hover
{
border-top: solid 1px #ffffff;
border-bottom: solid 1px #ffffff;
background-color: #cccccc;
}
</style>
</head>
<body>
<a name="top"></a>
<table>
<tr>
<td colspan="3">Header img goes here.</td>
</tr>
<tr>
<td colspan="3" id="description">&nbsp;</td>
</tr>
<tr>
<td id="navigation">
<a onMouseover="descript(1)" onMouseout="descript(0)" href="">Link one</a>
<a onMouseover="descript(2)" onMouseout="descript(0)" href="">Link two</a>
<a onMouseover="descript(3)" onMouseout="descript(0)" href="">Link 3</a>
<a onMouseover="descript(4)" onMouseout="descript(0)" href="">Link four</a>
<a onMouseover="descript(5)" onMouseout="descript(0)" href="">Link 5</a>
<a onMouseover="descript(6)" onMouseout="descript(0)" href="">Link 6</a>
<a onMouseover="descript(7)" onMouseout="descript(0)" href="">Link 7</a>
<a onMouseover="descript(8)" onMouseout="descript(0)" href="">Link 8</a>
<a onMouseover="descript(9)" onMouseout="descript(0)" href="">Link 9</a>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2"><a href="#top">Top</a> | <a href="javascript:bookmark()">Bookmark</a> |</td>
</tr>
</table>
</body>
</html>




And the script (scripts.js)
function descript(Link)
{
if(Link == 0)
{
document.getElementById('description').innerHTML="&nbsp;";
}
if(Link == 1)
{
document.getElementById('description').innerHTML="Description for link 1";
}
if(Link == 2)
{
document.getElementById('description').innerHTML="Description for link 2";
}
if(Link == 3)
{
document.getElementById('description').innerHTML="Description for link 3";
}
if(Link == 4)
{
document.getElementById('description').innerHTML="Description for link 4";
}
if(Link == 5)
{
document.getElementById('description').innerHTML="Description for link 5";
}
if(Link == 6)
{
document.getElementById('description').innerHTML="Description for link 6";
}
if(Link == 7)
{
document.getElementById('description').innerHTML="Description for link 7";
}
if(Link == 8)
{
document.getElementById('description').innerHTML="Description for link 8";
}
if(Link == 9)
{
document.getElementById('description').innerHTML="Description for link 9";
}
}

function bookmark()
{
url=window.location;
title=document.title;
if(navigator.appName == 'Microsoft Internet Explorer')
{
window.external.AddFavorite(url,title);
}
else if(navigator.appName == "Netscape")
{
window.sidebar.addPanel(title,url,"");
}
else
{
alert('Your browser doesn't support this bookmarking feature')
}
}

Thanks, :)
MattoThePotatto
 
Posts: 4
Joined: Wed Jun 25, 2008 7:20 am

Who is online

Users browsing this forum: No registered users and 4 guests