|
-
May 26th, 2004, 10:21 AM
#1
onMouseOver problems...
Howdy all... First timer on HTML and JavaScript, so forgive me for any stupid questions, but this one has both myself and my teacher baffled.
I have a page on Microsoft FrontPage, and when the page loads, it starts a clock in a text box. No biggy. Our problem is that we want the user to be able to move their mouse over a line of text and the window.status becomes the day of the week. It keeps telling us that my variable is undefined, and we don't know enough about function declarations to solve it on our own. Can anyone help me?
-
May 26th, 2004, 10:29 AM
#2
post your code please.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 26th, 2004, 10:30 AM
#3
Here goes...
Code:
<html>
<head>
<title>Current Time</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<script language="JavaScript">
<!--
function startclock(dayofweek)
{
var thetime=new Date();
var nday=thetime.getDay();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var AorP=" ";
if (nhours>=12)
AorP="P.M.";
else
AorP="A.M.";
if (nhours>=13)
nhours-=12;
if (nhours==0)
nhours=12;
if (nsecn<10)
nsecn="0"+nsecn;
if (nmins<10)
nmins="0"+nmins;
if (nday==0)
nday="Sunday";
if (nday==1)
nday="Monday";
if (nday==2)
nday="Tuesday";
if (nday==3)
nday="Wednesday";
if (nday==4)
nday="Thursday";
if (nday==5)
nday="Friday";
if (nday==6)
nday="Saturday";
dayofweek=nday
return dayofweek
document.clockform.clockspot.value=nday+", "+nhours+":"+nmins+":"+nsecn+" "+AorP;
setTimeout('startclock()',1000);
}
//-->
</script>
</head>
<script language="JavaScript">
</script>
<body onLoad="startclock(dayofweek)">
<a HREF="http://www.google.com" onMouseover="window.status=dayofweek; return true">**********
<form name="clockform">
<p>Current Time: <input TYPE="text" name="clockspot" size="15"></p>
</form>
<p>Place your mouse here!</a> </p>
<p> </p>
<p> </p>
</body>
</html>
********** denotes the error line.
-
May 26th, 2004, 11:02 AM
#4
Frenzied Member
Here's the code for DayOfTheWeek:
Code:
<script type="text/javascript">
function DayOfTheWeek() {
now = new Date()
day = now.getDay()
days_array = new Array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")
day = days_array[day-1] //I'm not sure about this line, it works today but try it again on monday
window.status = day
}
</script>
Call it like this:
Code:
<a href="#" onMouseOver="DayOfTheWeek()" onMouseOut="window.status=''">Move mouse here to see the day of the week.</a>
This function shouldn't have anything to do with the clock as yours seemed to do.
If you've managed to mess up your clock script, you can find plenty online, try either here or www.js-x.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|