Reputation: 608
I'm using this small javascript 'toolbox' from http://www.hunlock.com/blogs/Totally_Pwn_CSS_with_Javascript
So far my code works in Firefox and Chrome but not IE.
*EDIT* Nore in Firefox either..
I get an Invalid Argument error right where it calls the getCSSRule 'toolbox' function. http://d.pr/Ai5D and from DevTools http://d.pr/btFU
Here is the code in question:
function myModal() {
if (window.location.href.indexOf("#fr") != -1) {
getCSSRule("#MB_content").style.backgroundImage = "url('/mailer/img/bgimg-fr.jpg') !important";
Modalbox.show('mailer/myModal-fr.html', {title: 'Nouveau', width: 1000}); return false;
} else {
Modalbox.show('mailer/myModal-en.html', {title: 'Sign-Up', width: 1000}); return false;
}
}
function thankYou() {
getCSSRule("#MB_content").style.backgroundImage = "none !important";
getCSSRule("#modalWrap").style.minHeight = "0 !important";
}
You can see any of the other files here https://github.com/jwmann/Modal-Sign-up/tree/master/mailer
Upvotes: 0
Views: 327
Reputation: 22247
The docs for getCSSRule say it returns the style object. You are expecting it to return a DOM object.
So:
getCSSRule("#MB_content").style.backgroundImage = "url('/mailer/img/bgimg-fr.jpg') !important";
should be
getCSSRule("#MB_content").backgroundImage = "url('/mailer/img/bgimg-fr.jpg') !important";
However, the docs also give usage examples where it returns a DOM object. Confusing!
Part 2: With a bit more testing I found that:
Upvotes: 2