我怎样才能捕获:IE8中的内容之后?

cod*_*ple 7 javascript css internet-explorer-8

我正在将一个:after伪元素应用于显示我的媒体查询断点名称的正文,如下所示:

body::after {
  content: 'medium';
  display: none;
}
Run Code Online (Sandbox Code Playgroud)

这样做的原因可以在这里找到:http://adactio.com/journal/5429/

我想获得:after在IE8 中使用javascript 的内容值.

这是我为其他浏览器做的方式:

var breakpoint = window.getComputedStyle(document.body, ':after').getPropertyValue('content');
Run Code Online (Sandbox Code Playgroud)

但IE8不支持getComputedStyle(),我知道它支持currentStyle,但经过一些尝试后我无法正确使用它.

这是我尝试没有成功的事情:

var breakpoint = document.body.currentStyle.getPropertyValue('content');
Run Code Online (Sandbox Code Playgroud)

有人知道怎么做吗?

编辑: 在BoltClock的笔记之后我现在已经将我的css改为此(一个半冒号):

body:after {
  content: 'medium';
  display: none;
}
Run Code Online (Sandbox Code Playgroud)

在使用两个之前,内容甚至没有出现在IE8中,所以它没有任何回报.不幸的是我仍然无法让IE8返回内容.

我在尝试这个:

if (style = document.body.currentStyle) {
  for (var prop in style) {
    if (prop === 'content') {
      alert(prop);
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我什么都没得到,但是如果我换'content'了一些其他的财产'backgroundColor'就会发出警告.所以我想即使msdn将内容列为currentStyle http://msdn.microsoft.com/en-us/library/ie/ms535231%28v=vs.85%29.aspx的可用属性之一,它也不会实际上是回归它,除非我做错了什么.

cod*_*ple 1

经过多次尝试后我得出的结论是这是不可能的。但值得庆幸的是,我找到了一个 js 脚本,它完全实现了我所追求的目标。

https://github.com/JoshBarr/js-media-queries

以及使用 Jeremy Keith 的将断点标签放入正文中的技术:在将断点标签放入 html 元素的 font-family 中之后。这可以支持 ie8 以及 android 也无法返回 :after 内容的某些情况。