本帖最后由 jslang 于 2013-03-18 16:33:36 编辑

解决方案 »

  1.   

    非ie的用getComputedStyle(d,false).content就可以取得
    currentStyle.content怎么就不行啊<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title> new document </title>
    <style type="text/css">
    .m { 
    color: #ff0000;
    content: 'asdf';

    </style>
    </head>
    <body>
    <div class="m">777</div>
    <script type="text/javascript">
    var d = document.querySelectorAll(".m")[0];
    if(d.currentStyle)
    alert(d.currentStyle.content);
    else
    alert(window.getComputedStyle(d,false).content);
    </script>
    </body>
    </html>还有currentStyle.content属性在ie中是不是有别的作用
    因为currentStyle连用户自定义的属性都能取得。
      

  2.   

    In IE8, it is a mission impossible.在 IE8, 这大概是不可能的。因为,content 是用来定义 pseudo elements (比如,:before, :after).
    currentStyle, 是一般 DOM element 的属性,不能用于pseudo elements。
    首先,你就无法得到 pseudo elements (比如说用 getElementById)到了 IE9,微软也引入支持getComputedStyle(element, pseudo). 才有可能。