[Java] Firefox is pissing me off

SuicideTaxi
03-21-2007, 12:36 AM
Hi pumpkins,

I have this page (http://www.wsbn.com/reyvision) here, see.

And it's got some javascript in it that refreshes the "What's On My Mind" image, (every 30 seconds) and also refreshes the scrolling marquee message every 60 seconds.

The page works fine in IE and Opera, but for some reason I can't figure out, in Firefox generates the following error in the error console when it attempts to refresh the marquee:


Error: document.marquee has no properties
Source File: http://www.wsbn.com/reyvision.htm
Line: 75



I've tried it on different machines with different add-ons and so forth, but it still generates the error. Only in Firefox though!

Can anyone tell me wtf it's doing that and how I can fix it?

Thanks!

Dreka
03-21-2007, 01:04 AM
From the basic little test I just did using a dummy page, it looks like Firefox is complaining because the element you are trying to change the properties of doesn't exist when it initially parses the code. Putting the javascript code after the element you are trying to change seemed to fix things in my test, so I would give that a shot.

Might be an issue with changing properties of an iframe before it is declared in Firefox. It's too late for me to research further.

Edit: To put it in simpler terms in case you go :huh:, copy/paste that segment of your javascript code that changes the screenshot and marquee after the iframe element in the source of your page.

SuicideTaxi
03-21-2007, 01:24 AM
Good idea but no luck :(

Dreka
03-21-2007, 01:28 AM
Oh, one more idea before I head off to slumberland. Try calling the id instead of the document.name version of the property.

That would simply involve doing this:
<iframe name="marquee" src="reyvision-marquee.php" width="350" height="20" scrolling="no" frameborder="no" marginheight="1" marginwidth="1" align="middle">
becomes
<iframe id="marquee" src="reyvision-marquee.php" width="350" height="20" scrolling="no" frameborder="no" marginheight="1" marginwidth="1" align="middle">

In the javascript code...
function reloadmarquee() {
now = new Date();
var martxt = "reyvision-marquee.php" + "?" + now.getTime();
document.marquee.src = martxt;
mtimer = 60;
}
becomes
function reloadmarquee() {
now = new Date();
var martxt = "reyvision-marquee.php" + "?" + now.getTime();
marquee = document.getElementbyId("marquee");
marquee.src = martxt;
mtimer = 60;
}

SuicideTaxi
03-21-2007, 01:45 AM
Now I get this instead:


Error: document.getElementbyId is not a function
Source File: http://www.wsbn.com/reyvision.htm
Line: 75



But when I remove this line:


marquee = document.getElementbyId("marquee");


...it works, only I get the error:


Warning: Element referenced by ID/NAME in the global scope.
Use W3C standard document.getElementById() instead.
Source File: http://www.wsbn.com/reyvision.htm
Line: 75



This is like a fucking Catch-22 lol

Dreka
03-21-2007, 10:41 AM
Yeah, that's my bad... if you check my code, I forgot to capitalize one letter. It should be

marquee = document.getElementById("marquee");not

marquee = document.getElementbyId("marquee");This is why I generally avoid coding after 2AM. If you add the line back to the javascript with the correct capitalization, it should stop throwing up the warning.

SuicideTaxi
03-21-2007, 05:35 PM
Awesome

Works like a champ

Thanks man!

?B-MAN
03-27-2007, 05:51 AM
Saw the thread and jumped in because I just got done resolving a similiar issue on a site rebuild. Firefox is extremely fickle in regards to javascript. Its actually forcing things to be correct whereas IE is a tad forgiving. But sometimes I swear the object has no properties errors can get quite annoying in FF.