Moved to: WoodyHayday.com
Woody Hayday

Fresh Ideas

Hi there! This is my old blog, I don't hang around here much.
You can now find me trying to mix things up here:
Visit WoodyHayday.com Subscribe To My Email List

Firefox, why you mutate my css?

Quick post to remove the annoyance that is this bug from my short term memory, you would think this would work:

var newBGString = $(this).css('background-image');

…it does, but not in firefox. Say the background property was set to “url(someimage.png) top left no-repeat”, making the background-image property “url(someimage.png)” right? In every browser except firefox, yes, not for firefox. Firefox would set the var as “url(“someimage.png”)” and THEN complain that the var is not realistic when you go on to use it elsewhere.

Anyway ridiculous bug, almost as annoying is how simple, hacky and rough the fix is:

var newBGString = $(this).css('background-image').replace('"',''); 

So if your firefox doesn’t like background image swapping via js, try it, I guess…

This entry was posted in Browser Compatibility, Javascript, Web Development and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.
Woody Hayday

Comments Archive

Hi there. This is my old blog and it's archived, so you can no longer post new comments on this post (Firefox, why you mutate my css?).

Read my new blog about writing software and stories at WoodyHayday.com

The New Blog
WoodyHayday.com
A Quote..
"Give me the fruitful error any time, full of seeds, bursting with its own corrections. You can keep your sterile truth for yourself."
Vilfredo Pareto
Old Random Projects
    © Woody Hayday 2008-2017