Firefox 4.0 & JavaScript

Status
Not open for further replies.
Anyone finding some basic libraries are dieing in the new firefox 4.0? It's been beating its chest about super fast javascript support so I downloaded it and a lot of sites just plain don't work. Some of my own javascript is also failing with random nonsensical errors, e.g. it can't find something on a page from a simple getElementById even though it exists..

Anyone else getting that? I literally had to downgrade back to 3.6.x..
 
Mmmk, here's a quick example. Should be an ugly red input box with a color picker on the side of it, jquery colorpicker. Works fine in IE/Chrome/Safari/FF 3.6.x and below.. it's not even there for me in FF 4.0.

Do you see it?

I get no errors in the console.. I mean holy hell, it even works in opera and WINDOWS Safari *shudder*.

All I see is the "vastly faster javascript" dribble all over their site so, somethings up..

I even disabled every single addon and plugin I have, checked javascript settings, it's all stock and working fine *shrug*
 

technophile

Ars Legatus Legionis
23,768
I wouldn't say it works "fine" in Chrome or IE9. I get this in both:

sl4eq8.png


I'm guessing you're missing a css file or something, or you have "working" copies in your cache maybe.

Edit: Chrome shows the following in the console when loading the page; I suspect that's at least part of the problem. You probably have the images cached already.
Code:
GET http://www.ventriloservers.org/ventrilo/images/meta100.png 403 (Forbidden)
GET http://www.ventriloservers.org/ventrilo/images/color.png 403 (Forbidden)

(Note that you probably need to use jQuery 1.5.1 or newer to get full compatibility with IE9.)

I can't try Firefox 4 because I haven't installed it yet and firefox.com seems to be dead at the moment, but in 3.6.3 I don't even get the broken image, so there's no way to open the picker; 4 probably does the same thing.
 
Haha, oh yeah.. images might help (no the sources exist but it's a protected domain, all forbidden). My IP has access to it so I didn't even notice it, sorry.

I stuck the images in that little /wtf/ test folder, should be fine now.

Main point being, on FF4.0, you see absolutely nothing but the text 'Should be an input field with a color picker on right side'. There isn't even an input field.
 
Nope but, now it's using the latest.. I haven't installed FF4.0 again, I install/uninstalled it 3 times already haha. I'll try again in a few. I hope somehow that was it. If anyone else has FF4.0, let us know if you see the color picker please!

Yeah it most certainly must be having an issue with the color picker.. I use that picker a lot on one project so now I'm going to have to pick another picker ><. Anyone have a favorite?

I couldn't even find the menu item to open the error console in FF4.0.. Thankfully I remembered it was ctrl+shift+J and I saw no errors with that color picker code.

edit:

Forgot to say thanks for peeking at it. FF is so in your face about updating that eventually everyone will go over there and then everyones going to need to check all their code for this random broken stuff. This could be bad....
 

karmakaze

Ars Tribunus Militum
1,700
Subscriptor
No errors in Firebug either (and yeah, it's broken for me in Fx4 too, worked in Chrome).

edit: The issue on the Fx4 seems to be because the <form> is empty:

Firebug:
Code:
<form>

</form>
Chrome Dev console:
Code:
<form>
<input type="text" name="someColor" size="6" value="#FF0000" 
data-hex="true" id="color_370589706493" style="background-color: rgb(255, 0, 0); color: white; " class="mColorPickerInput mColorPicker"><span style="cursor:pointer;" id="icp_color_370589706493"><img src="http://www.jjtsoft.com/wtf/images/color.png" style="border:0;margin:0 0 0 3px" align="absmiddle"></span>
</form>
Is the source of this page a static HTML file, or is it being processed on the server? I didn't see any obvious other JS than jQuery and the mPicker.
 
It's just a static page, nothing dynamic about it, served straight with no processing. You can see in FF the source code all links correctly to the files needed.

An empty form certainly shouldn't invalidate it. The page I'm having trouble with has a full, regular form, and lots of those color pickers and it broke all of them in FF4.

I just opted to go with JPicker. It's a pretty good alternative with a (for me at least) more familiar interface. Gives you full H/S/V/R/G/B and hex inputs which is nice.

One thing I don't like about it is if you open a JPicker up and click anywhere else on the screen it should have added an event to close it down. It definitely also should have added in support for closing one if another is open. It does contain an array of pickers but has no API reference so I can't even really close them programatically myself haha. It's always something. The author did mention this in his notes at the bottom and a planned future optimization is using the same instance (closing any other instances or reiniting a single instance) for multiple pickers on the same page.

I'm mostly just posting this to be warned of this kind of thing on your own site.. As soon as FF4 is 'pushed' to everyone, all hell could break loose on your own sites.
 

technophile

Ars Legatus Legionis
23,768
karmakaze":1kfum6c0 said:
edit: The issue on the Fx4 seems to be because the <form> is empty
The form is empty (most likely) because the mPicker is doing something that is causing the input to be removed from the DOM. AFAIK Firefox/Chrome/etc no longer show you what the server actually sent when you hit view source; instead, they generate the source view from their own internal representation of the DOM.
 
It's the opposite for me. I haven't verified in FF4 but when I view source I see original server-fed source rather than DOM updates. I need to use firebug to see all the real dynamic content.

And yes, the 'type' of the input field is 'color' which I don't like. I like JPickers route of just using jQuery to find a class or ID and binding to that but still letting the text field be type='text'. I bet that's really screwing with FF4, because type='color' isn't valid.
 

DebtAngel

Ars Scholae Palatinae
1,027
ominous":2ijiuhod said:
It's the opposite for me. I haven't verified in FF4 but when I view source I see original server-fed source rather than DOM updates. I need to use firebug to see all the real dynamic content.

And yes, the 'type' of the input field is 'color' which I don't like. I like JPickers route of just using jQuery to find a class or ID and binding to that but still letting the text field be type='text'. I bet that's really screwing with FF4, because type='color' isn't valid.

For what it's worth, I copied the code over locally, removed the DOCTYPE, and got a little further ahead. It rendered the textbox, but clicking on the beachball didn't do anything.

What happens if you try to write this using an HTML 5 or HTML 4.01 DocType, rather than XHTML-1.0 Strict?
 

technophile

Ars Legatus Legionis
23,768
ominous":3anvxfg6 said:
It's the opposite for me. I haven't verified in FF4 but when I view source I see original server-fed source rather than DOM updates. I need to use firebug to see all the real dynamic content.
It's not truly one or the other; I didn't mean to imply it was an up-to-date view of the DOM, merely that it was generated from some internal representation of the original source rather than being the actual response from the server.

True dynamic content (like stuff added/modified by script running after page load) doesn't show up in View Source (in any browser, that I know of), but View Source isn't simply a text dump of the response sent by the server, either. (You can verify this by using Fiddler to capture the server response and comparing that to what Firefox presents -- although now I can't verify this on that page since the input is showing up in Firefox's View Source, so I guess I could be wrong about that :p.)

My guess, since you tested the DOCTYPE being part of the issue, is that as Firefox is building up its initial internal representation, is that since the input isn't valid, it's just getting silently dropped. When FF generates the text view of that representation, it's not included.
 
It just must be type='color' on it, it doesn't know what it is, drops it, never hits DOM, the script can't find it and then you're up the creek without a paddle.

I think I'm noticing some other bizarre behavior and I don't know if it's FF4 yet or not, I'll figure that out tonight. It seems like JS accessing any hidden (display:none;) object is having trouble overall. It's a wild guess but the form I use JPicker on hides a ton of panels on it and any instance I try to bind with JPicker that isn't visible at on body load don't get instantiated. I had to literally make the color picker panels all open for 2 seconds on page load to init them all and then hide them, so the page is very ugly when it first loads. I'm going to test that in other browsers and see if it's FF4. If it's FF4 then that explains a lot about the new engines behavior.. To 'feel' faster by only processing events that're immediately necessary? I'm not sure..
 
Never heard of that HTML5 element and the docs didn't specify it required HTML5. In the DOM you can use HTML like XML and set any attributes you like, as long as at execution time you correct the markup so it's valid. Clearly that's what this is doing.

FYI, you were right. I updated to the latest version of the picker and it now works with FF4. It's saving me a lot of time not having to convert to another picker. The other pickers are nice but they have some serious flaws. Most of them cannot spawn a picker properly that's bound to a html element in the correct position. JPicker is a freaking mess. Looks great, works horrifically. If the element isn't visible while you try to bind to it it outright fails in all browsers. Also if you change the position of any picker (say you display:block a div and it pushes some pickers down) it doesn't even dynamically account for this and the picker opens up in the wrong position (usually vertically higher or lower, off screen). Ug!

Thanks again, I love quick fixes!
 
karmakaze":wjgd6byc said:
According to this page, Opera 11 is the only one to support HTML5's color picker yet:

http://diveintohtml5.org/forms.html#type-color

Though this page seems to indicate that the other browsers have rudimentary support:

http://marxsoftware.blogspot.com/2011/0 ... icker.html
They don't, it's just that unknown input types fall back to a regular text input.
 
The only reason I like that colorpicker is it's single instance (only one open at a time) and doesn't fail to instantiate if it's currently display:none; hidden during page load. If anyone has any other pickers they like I'd love to know if they do this as well.

JPicker does have 'single instance' mode in the future patch notes, but nothing so far on the issue I submitted about not instantiating hidden elements.
 
Status
Not open for further replies.