понедельник, 27 февраля 2012 г.

javascript

function rzGetStyle(e,a){
  var v=null;
  if(document.defaultView && document.defaultView.getComputedStyle){
    var cs=document.defaultView.getComputedStyle(e,null);
    if(cs && cs.getPropertyValue) v=cs.getPropertyValue(a);
  }
  if(!v && e.currentStyle) v=e.currentStyle[rzCC(a)];
  return v;
};

------------------
<script>
function rzGetStyle(e,a){
  var v=null;
  if(document.defaultView && document.defaultView.getComputedStyle){
    var cs=document.defaultView.getComputedStyle(e,null);
    if(cs && cs.getPropertyValue) v=cs.getPropertyValue(a);
  }
  if(!v && e.currentStyle) v=e.currentStyle[rzCC(a)];
  return v;
};


window.onload = function ()
{
div = document.getElementById('info');
alert(div.style.width);
alert(rzGetStyle(div,'background-color'));
}

</script>

<style>
#info {
background-color: #ff0;
height: 200px;
}
</style>

<div id="info" style="width: 150px;">Hello </div> 
------------------------------------

<div id="info" style="width: 150px;" onclick="this.style.width = parseInt(this.style.width)-10+'px';">Hello </div>

------------------------------------














Комментариев нет:

Отправить комментарий