dimanche 3 juillet 2016

Creating a custom element in HTML, and want to force prevent editing its style

I'm making a custom element with a predefined style set, and I want to prevent changing them with inline styles, the style tag, or a stylesheet.

I've tried to set every CSS atribute to default after document load, but that didn't work.

// µ = document.getElementsByTagName('custom-tag');
! function () {
  document.onload = function () {
    y = µ[x].style;
    for (x = 0; x < µ.length; i++) {
      eval(JSON.stringify(y).replace('{"', 'y.').replace('"}', '"').split('":').join('=').split(',"').join('; y.'))
    }
    µ[x].setAttribute('style', '');
    y.cssText = "";
    y.width = "2em";
    y.height = "1em";
    y.margin = "0";
  }
} ();

Is there such a way to do this?

Aucun commentaire:

Enregistrer un commentaire