473,385 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1528
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: STEPHEN GOODE | last post by:
I had a client upgrade his PHP from 4.? to 4.3.9. An important script stopped working. It seems to work fine, but it uses the mail() function and sendmail to send notifications. The email never...
2
by: Dag Sunde | last post by:
I have the following code fragment in one of my pages: if (typeof document.getElementById('myApplet').getTableAsSDV != 'undefined') { rowBuffer =...
1
by: Mark | last post by:
Hi - on my site, overnight, my submit buttons have suddenly stopped working in IE. Firefox is fine. The link button works perfectly - the two submit buttons however do not. It works in IE...
3
by: Aahz | last post by:
I have big asp.net , c# project with many buttons and image buttons that suddenly stop firing, when you click on button form -nothins happen. What strange that in Firefox they are still work...
1
by: Chris | last post by:
ASP.NET 2.0 was working fine, then I installed XP SP2 an it stopped working. Unfortunately I do need SP2 so going back to SP1 is not an option. I am quite certain that it was working for a while...
2
latitude
by: latitude | last post by:
Have had a few questions here but no replies so far so thought id give it one more go: Im working on a textviewer/editor and have used autodetect url on it, and it has worked fine. But somewhere...
3
by: Mark Brown | last post by:
I left a message here yesterday asking why the paging and sorting of my datagrid wasn't working. Today, I created an identical datagrid and associated code for paging and sorting called DataGrid2....
0
by: Robin Tucker | last post by:
Hi, Previously when I go to the head of an item and type ''', I got an XML comment auto-complete in my source (most useful). Recently its stopped working. Is there some simple setting I need...
2
by: Jake Barnes | last post by:
I've been asked to help out with the navigation bar on this page: http://www.thesecondroad.org/ The drop down menu (which is pure CSS, save for a fix for IE) appears behind the Flash module....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.