SOLVED

Re: use mktoBoolean in if statement

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

Re: use mktoBoolean in if statement

Has nothing to do with XHR cross-domain security.

The problem is actually quite basic. This is not a valid style assignment:

// broken, you can't assign CSS text here

document.getElementById('main-content-id').style.width = '100% !important';

That line is valid JavaScript, but it doesn't actually do anything. You can't simply assign the CSS text '100% !important' as if it's the value of the width property.  It's actually two values, one being the '100%' and the other being the special reserved priority attribute (whose only allowed value is the string 'important').

To set !important in script, use setProperty, which includes the priority:

document.getElementById('main-content-id').style.setProperty('width','100%','important')

Anonymous
Not applicable

Re: use mktoBoolean in if statement

well what do you know, thank you! I know I thought about setProperty yesterday but I didn't even try..

SanfordWhiteman
Level 10 - Community Moderator

Re: use mktoBoolean in if statement

There's also a significant JS bug on your page in another area.

You have code that tries to style a Marketo form after document.ready/DOMContentLoaded fires.  You can't do this.  If you want to apply styles to the Marketo Forms 2.0 DOM, add them in the Forms 2.0 whenReady event.  Otherwise, it will never work reliably.

Anonymous
Not applicable

Re: use mktoBoolean in if statement

and thank you again, will look into this.