2

I'm attempting to adjust some elements on a page dynamically when it gets resized (or opened on smaller displays). There is a piece of code that looks roughly like this:

$('some_id').setStyle({'margin-left':'200px'});

And it works as intended in Chrome but is failing in Firefox with no JavaScript warning or errors. And to be clear I have inspected the element in Firefox. It's straight up just not getting the style set. If I manually add in this rule with the inspector it works as intended.

More code has been requested:

function reset_ad_size() {
    topAlign($('leftColumn'), $('adContentLeftFloat'));
    leftSide = leftAlign($('mainBodyFrame'), $('adContentLeftFloat'));
    leftSide -= 190;

    if(leftSide < 0) {
        $('site_wrap_neo').setStyle({'margin-left':'200px'});
        leftSide = 5;
    }
    $('adContentLeftFloat').setStyle({left:leftSide+'px'});
}

document.observe("dom:loaded", function() {
  reset_ad_size();
  window.onresize = function() {
    reset_ad_size();
  }
});
Geek Num 88
  • 5,264
  • 2
  • 22
  • 35
Austin DeVinney
  • 273
  • 3
  • 12
  • 1
    I've edited the post with an update to the code. – Austin DeVinney Jul 02 '13 at 17:15
  • JavaScript is enabled and I mean when you right click and say "Inspect element with Firebug". It's called the inspector in Chrome, methinks. But yeah -- when I manually add in that rule in Firebug (the margin-left), then it appears to render properly. – Austin DeVinney Jul 02 '13 at 17:22

1 Answers1

3

I found the problem and wound up fixing it with this:

$('site_wrap_neo').style.marginLeft='200px';

For whatever reason Firefox didn't like the setStyle from Scriptaculous on that.

Austin DeVinney
  • 273
  • 3
  • 12
  • 2
    to use `setStyle()` correctly you need to use the camel case. `$('site_wrap_neo').setStyle({'marginLeft':'200px'})` – Geek Num 88 Jul 02 '13 at 19:34