JS not working on FF

software development

#1

For some reason Fire Fox does not execute my javascripts. They are very simple scripts–just toggling whether the style attribute of a div tag is set to “inline” or “none” but for some reason it only works on IE and Opera (and I think Netscape was OK too), but not Fire Fox.

Any suggestions? You can “view source” on this page if you need the code: My Site

Also, while we’re on the topic of browsers (even though really this probably should be a new thread)… I would like to know what people think of Fire Fox. It seems like a LOT of people have started highly recomending FF, but the way I see it, if over 90% of internet users use Internet Explorer, then regardless of whether or not Fire Fox really displays code more accurately (I read somewhere that it does not), Internet Explorer seems like the way the internet was ment to be viewed. I mean, it doesn’t really matter what the code should look like, it’s all about what the designer ment for it to look like (yes, I know it’s my own fault if my site looks crappy on other browsers, but still I want to see what other people ment for their sites to look like when I visit them, not what the code would be if it were perfect). Those are just my thoughts, feel free to criticize.


#2

There used to not be a standards for the web browsers to follow for new technologies such as using JavaScript to manipulate the web page. So browser developers came up with their own. However eventually standards such as Document Object Model (DOM) Level 2 Core Specification has since been released and while browser developers strive to support the new standards they obviously can’t stop supporting the non-standard behavior cold turkey.

Having said that if you have taken the time to read the DOM specification you would know the method used to obtain an element object with a given ID is document.getElementById

The non-standard behavior you are witnessing in Internet Explorer and Opera is a shortcut implemented for lazy developers. The collection of elements given IDs is like a bucket of widgets with labels on them. Either you can search the bucket each time you need a widget, or you can just dump the bucket out on your desk. Just like a negative side affect would be a cluttered desk, automatically assigning references to every element object with an ID results in something called namespace pollution. That might not be something you are concerned with given the tiny nature of the code you are using, but it is significant to grander applications of JavaScript such as rich-text editors and AJAX etc.

:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


#3

you should install FireBug https://addons.mozilla.org/en-US/firefox/addon/1843
when developing javascript on firefox, it is awesome.

Firefox is actually at 33% these days!
http://www.w3schools.com/browsers/browsers_stats.asp

38% use ie6, which is broken when compared to ie7. Interestingly enough when you look at visitors to our panel which is a more tech savvy crowd, firefox usage is 65%! You pretty much have to design to have your site look good in all browsers at this point, even the broken ones.


#4

Thanks, I’ll download it right after I finish posting this.

Atropos7: I will start using document.getElementByID in my scripts.

EDIT: After looking it over, is there no way to use a variable in document.getElementByID? All the examples always have a string in the parameter. But my script passes the JS function a div. I tried a few different ways to use a variable, but the only way I can get it to work is with a string written directly in the parameter.

I found another incompatability in my marquees. I was looking around on developer.mozilla.org and found this http://developer.mozilla.org/en/docs/HTML:Element:marquee which seems to be just the same as in Internet Explorer, but in FireFox the marquee never stops. According to that site Mozilla does follow the loop attribute, so IDK what I did wrong. I made a test page so you can see what I’m talking about: marquee test


#5

isn’t in any HTML specification I’m aware of. It’s a Microsoft add-on that is partially supported by other browsers. The Netscape-created element is another partially-supported element that is not in any HTML specification, along with the rather popular .

I hate it when browsers support non-standard elements. It can lead to horrible things.


si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#6

Yeah, I agree that marquee is easily abused. But I am only using it for a simple animation that is in a corner and out of the way. And this particular thing I don’t really care that much if it isn’t displayed correctly because it is not as big a deal as the previous problem I had. And speaking of which… If I pass the div id in quotes, then it seems to work just fine, so never mind about the last thing about the getElementByID not working, it’s fine now, thanks for the help.