PDA

View Full Version : Trouble getting script to run


darlene
02-04-2003, 10:18 PM
I have cut and pasted the script I like in the <head> section of my page. I then pasted the part in the <body> but get the following:
Tue Feb 4 14:13:22 PST 2003 <body >
this is supposed to be a script running in the status bar and saying things while giving the day and time.
What am I doing wrong?:(

joeframbach
02-04-2003, 10:34 PM
try window.status="Tue Feb 4 14:13:22 PST 2003"

its a shot in the dark, seeing as how you didnt post any code and i have no clue what you are talking about

darlene
02-04-2003, 10:51 PM
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<script language="javascript">
<!--hide


// *Time-of-Day Messages Status Bar*

// Copyright © Blake Birkenfeld, 1998

// Free for use as long as this is left in place.

// < ktbbirk@hiplains.net >

// www.geocities.com/SiliconValley/Campus/4310/

// http://welcome.to/blake

// Note: Be sure to place the following in the Body tag: //onLoad="Change();Place();Time()"



txt = ""
txtt = ""
txttt = ""
function Time() {
var now = new Date();
var time = now.getHours();

//Change the 3 messages to your liking.
//DO NOT USE CONJUCTIONS OR ANY APOSTROPHES

//late night - very early morning
if (time > 23 && time < 6) { txt = 'Good Evening';
txtt = 'Welcome to the District of Lake Country website';
txttt = 'The Place Where You Belong'}
//early morning
else if (time > 5 && time < 8) { txt = 'Good Morning';
txtt = 'Welcome to the District of Lake Country website';
txttt = 'The Place Where You Belong!'}
//end of morning
else if (time > 7 && time < 12) { txt = 'Good Morning';
txtt = 'Welcome to the District of Lake Country website';
txttt = 'Remember to take a video tour before you leave'}
//afternoon
else if (time > 11 && time < 17) { txt = 'Good Afternoon';
txtt = 'Welcome to the District of Lake Country website';
txttt = 'Have you taken your video tour yet?'}
//evening - night
else { txt = 'Good Evening';
txtt = 'Welcome to the District of Lake Country website';
txttt = 'The Place Where You Belong!'}
}



//Leave this stuff alone. It is required for later.
var worddd = 0
var word = 0
var wordd = 0
var msg
var timeI
var timeII
var timeIII
var timeIIII

function Change() {
if (word < txt.length+1) { word++;
timeI = setTimeout("Change()", 100) }
else if (word > txt.length) { clearTimeout(timeI);
Changee() }
}

function Changee() {
if (wordd < txtt.length+1) { wordd++;
timeIII = setTimeout("Changee()", 100) }
else if (wordd > txtt.length) { clearTimeout(timeIII);
Changeee() }
}

function Changeee() {
if (worddd < txttt.length+1) { worddd++;
timeIIII = setTimeout("Changeee()", 100) }
else if (worddd > txttt.length) { clearTimeout(timeIIII);
word = 0; wordd = 0; worddd = 0; Change() }
}

function Place() {
if (word < txt.length+1) msg = txt.substring(0, word)
else if (word > txt.length && wordd < txtt.length+1) msg = txtt.substring(0, wordd)
else if (wordd > txtt.length && worddd < txttt.length+1) msg = txttt.substring(0, worddd)
else if (worddd > txttt.length) msg = txt.substring(0, word)
window.status = msg
timeII = setTimeout("Place()", 100)
}


//-->
</script>
</head>
<SCRIP> <script language="JavaScript">
var now = new Date(); document.write(now);
</script> </SCRIPT>

<body //onLoad="Change();Place();Time()">

<STRONG><FONT face=Arial><SMALL><SMALL><FONT size=3>&lt;body
</FONT></SMALL></SMALL><FONT
color=#ff0080></FONT>&gt;</FONT></STRONG>

</body>

</html>

This is the script and how I tried to put it into a page. The previous note was what shows up in the browser when I view it.
Thanks for being so helpful, but I am truely new to this and appreciate all the help I can get.:o

whammy
02-05-2003, 12:48 AM
The main problem is you had malformed HTML - you had script tags within script tags, and had //onload in the body tag... I cleaned it up for you:


<html>
<head>
<title>New Page 1</title>
<script language="javascript">
<!--
// *Time-of-Day Messages Status Bar*
// Copyright © Blake Birkenfeld, 1998
// Free for use as long as this is left in place.
// < ktbbirk@hiplains.net >
// www.geocities.com/SiliconValley/Campus/4310/
// http://welcome.to/blake
// Note: Be sure to place the following in the Body tag: //onLoad="Change();Place();Time()"

var txt = ""
var txtt = ""
var txttt = ""
function Time() {
var now = new Date();
var time = now.getHours();

//Change the 3 messages to your liking.
//DO NOT USE CONJUCTIONS OR ANY APOSTROPHES

//late night - very early morning
if (time > 23 && time < 6) {
txt = 'Good Evening!';
txtt = 'Welcome to the District of Lake Country website!';
txttt = 'The Place Where You Belong!'
}
//early morning
else if (time > 5 && time < 8) {
txt = 'Good Morning!';
txtt = 'Welcome to the District of Lake Country website!';
txttt = 'The Place Where You Belong!'
}
//end of morning
else if (time > 7 && time < 12) {
txt = 'Good Morning!';
txtt = 'Welcome to the District of Lake Country website!';
txttt = 'Remember to take a video tour before you leave!'
}
//afternoon
else if (time > 11 && time < 17) {
txt = 'Good Afternoon!';
txtt = 'Welcome to the District of Lake Country website!';
txttt = 'Have you taken your video tour yet?'
}
//evening - night
else {
txt = 'Good Evening';
txtt = 'Welcome to the District of Lake Country website';
txttt = 'The Place Where You Belong!'
}
}

//Leave this stuff alone. It is required for later.

var worddd = 0;
var word = 0;
var wordd = 0;
var msg;
var timeI;
var timeII;
var timeIII;
var timeIIII;

function Change() {
if (word < txt.length+1) {
word++;
timeI = setTimeout("Change()", 100);
}
else if (word > txt.length) {
clearTimeout(timeI);
Changee();
}
}

function Changee() {
if (wordd < txtt.length+1) {
wordd++;
timeIII = setTimeout("Changee()", 100);
}
else if (wordd > txtt.length) {
clearTimeout(timeIII);
Changeee();
}
}

function Changeee() {
if (worddd < txttt.length+1) {
worddd++;
timeIIII = setTimeout("Changeee()", 100);
}
else if (worddd > txttt.length) {
clearTimeout(timeIIII);
word = 0;
wordd = 0;
worddd = 0;
Change();
}
}

function Place() {
if (word < txt.length+1) msg = txt.substring(0, word)
else if (word > txt.length && wordd < txtt.length+1) msg = txtt.substring(0, wordd)
else if (wordd > txtt.length && worddd < txttt.length+1) msg = txttt.substring(0, worddd)
else if (worddd > txttt.length) msg = txt.substring(0, word)
window.status = msg
timeII = setTimeout("Place()", 100)
}

// -->
</script>
</head>

<body onload="Change();Place();Time()">

<script type="text/javascript">
<!--
var now = new Date(); document.write(now);
// -->
</script>

</body>
</html>


:)

darlene
02-05-2003, 04:52 PM
Thank you so very much for the code. I have for some reason drawn a very big blank spot. I use FP to work in and copied and pasted the code, saved the code to file (shows as an htm file). Then when I open my browser and click open file (to the saved htm file) it displays all the code in the window.

I must be doing something very simply wrong and am just to stupid to pick it out. Can I beg upon you for assistance once again.

as a p.s. I am slowly working my way through the tutorials and find doing things hands on a major assistance in my learning process, so sorry for being such a pest!:confused:

joeframbach
02-05-2003, 05:21 PM
programs such as FP usually mutilate your code. get a text-only editor like www.editplus.com for JS stuff. FP is usually only good for design time.

darlene
02-05-2003, 05:30 PM
Any ideas of how I incorporate from the text editor to FP for publishing to my host? If FP strips the code I can I then incorporate it?

whammy
02-05-2003, 11:43 PM
At the bottom of your FP window, you should see three tabs... I forget exactly what they say (since I despise FrontPage)... but one is like "design", another is "source" or something.... you'd want to paste pure code in the "source" window.