Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function works in NS & IE but not FF - Why?

Status
Not open for further replies.

mmerlinn

Programmer
May 20, 2005
748
US
Can anyone tell me why this does not work in FF? It works perfectly in IE & NS, but for some reason FF thinks the IF statement is always false.

[tt]
function Writeheader(){
nowdate = new Date();
nowyear = nowdate.getYear();
yearmod = nowyear % 10;

if (Begindate(window['sdate_' + yearmod]) * Stopdate(window['edate_' + yearmod]) > 0){
Writeclosed(nowyear); (Only IE & NS do this)
}
else{
Writedefaultblurb(); (FF always does this)
}
}
[/tt]


I assume there is something wrong in the IF line, but darned if I can see what the problem could be.

Thanks in advance for any help.


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
This is weird.

When I started this thread, FF was not working while IE & NS were.

All were supposed to kick in on the 16th of this month. IE & NS did. FF kicked in on the 19th and is now working.

I checked system dates and all are correct, but for some reason FF slept in for three days.

Since it is now working I am not going to spend any more time trying to figure out why it kicked in three days late.

BabyJeffy::

What is the reasoning behind using a double set of brackets to enclose the calculation?


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
BabyJeffy::

Cancel that last question. I see why you did it.


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
mmerlinn, is it possible FF had cached the page and was still using a local copy with outdated code?

It would be worth setting up a test with a different date to see if it works correctly or waits an additonal 3 days.
You are likely to use this or something like it again and it would be nice to know why it failed.


At my age I still learn something new every day, but I forget two others.
 
You can always monkey with your system date. Just make sure to change it back before sending any emails or doing anything else with a date stamp. Also resave your code after setting it back!
 
theniteowl

I found one possible place in the code that could have caused the problem (not sure, but the code was not FF compliant) and have since rewritten it along with several functions to be FF compliant.

Have no idea whether FF was caching it, and have no way of finding out.

Did monkey with system dates, but to no avail.

So now I will just wait another year and see if I have created another problem.


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
I am using getYear, but that definitely is not the problem. I looked up an old version of the function I was having problems with and in 2005 getYear was working perfectly in FF, so unless FF changed the handling of getYear in the last year (highly unlikely), there is no way it could have been the problem now, especially since the new re-written functions still use getYear and they seem to work ok.

This page ( is an example of the code used.









mmerlinn

"Political correctness is the BADGE of a COWARD!"
 
BillyRayPreachersSon

I just noticed something.

You noted that I was using getYear vs getFullYear. In the sample code in the original inquery above it really does not matter whether the full year is returned or not. We are only concerned with the last digit of the year which will be the same regardless whether we use getYear or use getFullYear.


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
Have you tried putting an alert() before your if statement to see what value is in yearmod? Try that to see which variable is causing the trouble.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top