Jump to content

User:Dialectric/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dialectric (talk | contribs) at 16:37, 25 September 2020. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//------------------------------------------------------
// recolor test
//------------------------------------------------------

function ready(callback){
    // in case the document is already rendered
    if (document.readyState!='loading') callback();
    // modern browsers
    else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback);
    // IE <= 8
    else document.attachEvent('onreadystatechange', function(){
        if (document.readyState=='complete') callback();
    });
}

ready(function(){
    // do something
        var target = document.querySelectorAll('div');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        var target = document.querySelectorAll('h2');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        var target = document.querySelectorAll('table');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        var target = document.querySelectorAll('th');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        var target = document.querySelectorAll('tr');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        var target = document.querySelectorAll('td');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
         element.style.backgroundColor = "#999";
        });
        var target = document.querySelectorAll('caption');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
});