User CSS initialization fix (issue #138)
* Now we use onload event to disable user CSS accoring to default or user settings. Problem was that we were setting the 'disabled' attribute on unloaded stylesheet. This should work in all moderen browsers.
This commit is contained in:
parent
e341a3e97c
commit
9d87e59356
1 changed files with 17 additions and 1 deletions
|
@ -375,7 +375,23 @@ VT100.prototype.initializeUserCSSStyles = function() {
|
||||||
style.setAttribute('rel', 'stylesheet');
|
style.setAttribute('rel', 'stylesheet');
|
||||||
style.setAttribute('type', 'text/css');
|
style.setAttribute('type', 'text/css');
|
||||||
document.getElementsByTagName('head')[0].appendChild(style);
|
document.getElementsByTagName('head')[0].appendChild(style);
|
||||||
style.disabled = !enabled;
|
|
||||||
|
// If stylesheet needs to be disabled we need to do that from onload
|
||||||
|
// event, otherwise 'disabled' attribute will be ignored.
|
||||||
|
if (!enabled) {
|
||||||
|
if ('onload' in style) {
|
||||||
|
style.onload = function(style) {
|
||||||
|
return function () {
|
||||||
|
style.disabled = true;
|
||||||
|
}
|
||||||
|
}(style);
|
||||||
|
} else {
|
||||||
|
// If onload event is not supported we will try to do it the old
|
||||||
|
// way. This also works sometimes, mosty in cases when browser
|
||||||
|
// already has cached version of stylesheet.
|
||||||
|
style.disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add entry to menu
|
// Add entry to menu
|
||||||
|
|
Loading…
Reference in a new issue