469,623 Members | 1,545 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Why has this stopped working in the new Firefox

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[i]==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","Novem ber","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'; }
}

Nov 12 '06 #1
2 1376
Lee
fe********@gmail.com 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[i]==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","Nove mber","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()
--

Nov 12 '06 #2
fe********@gmail.com 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?
<snip>
ValidYear = find(pubYear, today.getYear());
getYear() 106 for 2006 in FF2.0.

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

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by STEPHEN GOODE | last post: by
1 post views Thread by Mark | last post: by
1 post views Thread by Chris | last post: by
3 posts views Thread by Mark Brown | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.