Ask a Question related to Macromedia Dynamic HTML, Design and Development.
-
Disc Dogger #1
Safari Java Script Problem
OK, I don't know anything about Java Script and am not a programmer, but I
found some code that I wanted that would give me a live countdown timer on my
website. I followed the directions from the site where I got the code and
previewed it in Firefox. It worked! Yea!. I uploaded it to my site as a test
page, along with the two scripts it required, and it continued to work in
Firefox. I ran over to our PC, only used for this type of heavy lifting, and it
worked there too. Unfortunately, when viewed on Safari, nothing showed up.:-(
Coming from a print background, this web kind of vodoo drives me crazy.
Can someone please provide me a fix? I know that it's only a small number of
web users out there who use Safari, but I'd like not to exclude them,
especially because I am a Mac enthusiast. And, damn it, it should work...:-)
The page can be viewed here: [url]www.hyperflite.com/indextest.html[/url]. The timer is
supposed to appear in the yellow bar at the top and does so in Firefox.
Here is the first script:
var myCountdown = new Array();
var repeat = false;
function checkPlural(noun, value) {
noun = ((value == 1) || (value == 0)) ? noun : (noun += "s");
return noun;
}
function updateDisplay(text, id) {
var tag = document.getElementById(id);
if (tag.firstChild) {
tag.firstChild.nodeValue = text;
}
else {
textNode = document.createTextNode(text);
tag.appendChild(textNode);
}
return;
}
function doCountdown() {
for (i = 0; i < myCountdown.length; i++) {
if (!myCountdown.expired) {
var currentDate = new Date();
var eventDate = myCountdown.eventDate;
var timeLeft = new Date();
timeLeft = eventDate - currentDate;
msPerDay = 24 * 60 * 60 * 1000;
msPerHour = 60 * 60 * 1000;
msPerMin = 60 * 1000;
msPerSec = 1000;
daysLeft = Math.floor(timeLeft / msPerDay);
hoursLeft = Math.floor((timeLeft % msPerDay) / msPerHour);
minsLeft = Math.floor(((timeLeft % msPerDay) % msPerHour) / msPerMin);
secsLeft = Math.floor((((timeLeft % msPerDay) % msPerHour) % msPerMin) /
msPerSec);
day = checkPlural("day", daysLeft);
hour = checkPlural("hour", hoursLeft);
minute = checkPlural("minute", minsLeft);
second = checkPlural("second", secsLeft);
if ((daysLeft == 0) && (hoursLeft == 0) && (minsLeft == 0) && (secsLeft
== 0)) {
updateDisplay(myCountdown.onevent, myCountdown.tagID);
}
else {
if (daysLeft <= -1) {
updateDisplay(myCountdown.afterevent, myCountdown.tagID);
myCountdown.expired = true;
}
else {
updateDisplay("Only " + daysLeft + " " + day + " " + hoursLeft + " "
+ hour +
" " + minsLeft + " " + minute + " " +
secsLeft + " " + second + " until the " +
myCountdown.event, myCountdown.tagID);
repeat = true;
}
}
}
}
if (repeat) {
repeat = false;
window.setTimeout("doCountdown()", 1000);
}
else {
return;
}
}
function setEventDate(year, month, day, hour, minute, second) {
this.eventDate = new Date(year, month - 1, day, hour, minute, second);
return;
}
function addCountdown(countdown) {
myCountdown[myCountdown.length] = countdown;
return;
}
function Countdown() {
this.tagID = "";
this.eventDate = new Date();
this.setEventDate = setEventDate;
this.event = "";
this.onevent = "";
this.afterevent = "";
this.expired = false;
}
The second script is:
var mycountdown = new Countdown();
with (mycountdown) {
tagID = "mycountdowndiv";
setEventDate(2006, 9, 23, 10, 0, 0);
event = "2006 Hyperflite Skyhoundz World Championship";
onevent = "The moment you have been waiting for...!";
afterevent = "Congratulations 2006 Hyperflite Skyhoundz World Finalists!";
}
addCountdown(mycountdown);
TIA
Disc Dogger Guest
-
help with java script
Hi, can someone please help me. on my page http://www.watersportsproducts.com/store2/test.htm - I can not get the java script to return the right... -
CF Grid / Java Script / Action Script
Hi, Does anyone know of a good reference for the attributes CFgrid exposes in a flash form? eg. I would like to select the first row on load. ... -
Java popup within a php script???
Hey all, I want to add a Java Alert to ask the user if they are sure they want to Delete some data from the DB. Has anyone done this. I can get... -
Mac and Java Script?
Hello. I have an asp page with java script that calls a clicked event on some radio buttons. It works as expected except for Mac users. They are... -
Do you need to use Java script in ASP .Net?
Hi, Experts, With the great functionalities in ASP .net, do we still need to use JavaScript? Thanks Jerry



Reply With Quote

