This project is archived and is in readonly mode.
Assets.css doesn't support onload event for all browsers
The Assets.css does not support the onload property. This is because only IE and Opera fire the onload event when the stylesheet is loaded. Other browsers such as Firefox, Chrome and Safari do not listen on the event. To get around this, you will need to play around with a timer and the ownerNode properties.
I explain the full solution here, plus some MooTools code of how
to get around it:
Comments and changes to this ticket
- Tag changed from css, assets.css, chrome, event, firefox, safari to css, assets.css, chrome, event, firefox, safari
Here is a working patch that works for 1.2 and 1.3.
It uses a timeout interval that compares DOM properties in a loop.
Unlike the link provided, it DOES NOT include any extra HTTP request to test a failed image.
Check it out, and please include the patch into the MooTools core.
- Milestone set to 188.8.131.52
- Assigned user set to Arian
- Milestone order changed from 197585 to 0
This should fix it: https://github.com/arian/mootools-more/compare/fix-547
You are aware the solution added only works for stylesheets loaded within the same-origin policy. If you have a stylesheet that is on a different subdomain, domain or maybe even port, then the DOM won't be able to access the cssRules (or rules for IE) array (it will throw a security exception).
Instead, remove the cssRules part and only check for the sheet DOM property. It will work for both.