Why has this stopped working in the new Firefox

F

fedorpawel

I want to redirect the user to the current month such as
November2006.html, but only if the month exists in pubMon array. This
code works correctely in IE but stopped working in the new Firefox. In
Firefox it always redirects to the default Annoucments.html. What am I
missing?
Thanks for any help.

/////Returns true if the val is an element of the array a

function find(a, val){
var b = false;
for(i=0;i<a.length;i++){
if(a==val) { b = true;}
}
return b;
};

/////This function does the redirecting.

function CurrMonth() {
today = new Date();
m = new
Array("January","February","March","April","May","June","July","August","September","October","November","December");

pubMon = new Array("8", "9", "10", "11", "12");
pubYear = new Array("2006");

ValidMonth = find(pubMon, today.getMonth() + 1);
ValidYear = find(pubYear, today.getYear());

if (ValidMonth && ValidYear) { window.location = m[today.getMonth()] +
today.getYear() + ".html"; }
else { window.location = 'Announcements.html'; }
}
 
L

Lee

(e-mail address removed) said:
I want to redirect the user to the current month such as
November2006.html, but only if the month exists in pubMon array. This
code works correctely in IE but stopped working in the new Firefox. In
Firefox it always redirects to the default Annoucments.html. What am I
missing?
Thanks for any help.

/////Returns true if the val is an element of the array a

function find(a, val){
var b = false;
for(i=0;i<a.length;i++){
if(a==val) { b = true;}
}
return b;
};

/////This function does the redirecting.

function CurrMonth() {
today = new Date();
m = new
Array("January","February","March","April","May","June","July","August","September","October","November","December");

pubMon = new Array("8", "9", "10", "11", "12");
pubYear = new Array("2006");

ValidMonth = find(pubMon, today.getMonth() + 1);
ValidYear = find(pubYear, today.getYear());


That shouldn't have worked in the old Firefox either,
because today.getYear() will return "106".
If you want "2006", you should be using today.getFullYear()


--
 
R

Randy Webb

(e-mail address removed) said the following on 11/12/2006 12:56 AM:
I want to redirect the user to the current month such as
November2006.html, but only if the month exists in pubMon array. This
code works correctely in IE but stopped working in the new Firefox. In
Firefox it always redirects to the default Annoucments.html. What am I
missing?

ValidYear = find(pubYear, today.getYear());

getYear() 106 for 2006 in FF2.0.

Change your code to use getFullYear() instead and it works properly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top