»
AnglaisFran�aisVietnamien

Imprimer - getStyle - JavaScriptBank.com

Version compl�te: jsB@nk » Snippet » getStyle
URL: https://www.javascriptbank.com/getstyle.html

getStyle © JavaScriptBank.comUtilisez cette Extrait de JavaScript pour obtenir le rendu d'un élément de style. Rapide et simple à mettre en œuvre.

Version compl�te: jsB@nk » Snippet » getStyle
URL: https://www.javascriptbank.com/getstyle.html



JavaScript
<script language="javascript">// Created by: Robert Nyman :: http://www.robertnyman.com//*  Example call of the function:    getStyle(document.getElementById("container"), "font-size");*/// The regular versionfunction getStyle(oElm, strCssRule){  var strValue = "";  if(document.defaultView && document.defaultView.getComputedStyle){    strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);  }  else if(oElm.currentStyle){    strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){      return p1.toUpperCase();    });    strValue = oElm.currentStyle[strCssRule];  }  return strValue;}// The version if you expect any IE 5.0 users whatsoeverfunction getStyle(oElm, strCssRule){  var strValue = "";  if(document.defaultView && document.defaultView.getComputedStyle){    strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);  }  else if(oElm.currentStyle){    try {      strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){        return p1.toUpperCase();      });      strValue = oElm.currentStyle[strCssRule];    }    catch(e){      // Used to prevent an error in IE 5.0    }  }  return strValue;}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<p align=center id=demo style="text-align: center;">JavaScriptBank.com</p><script>alert(getStyle(document.getElementById("demo"),7));</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->