I apply the :after pseudo-element to the body displaying the name of the breakpoint of my media request as follows:
body::after { content: 'medium'; display: none; }
The reason for this can be found here: http://adactio.com/journal/5429/
I want to get the value of :after content using javascript in IE8.
Here's how I do it for other browsers:
var breakpoint = window.getComputedStyle(document.body, ':after').getPropertyValue('content');
But IE8 does not support getComputedStyle() , I know that it supports currentStyle instead, but after several attempts I could not use it correctly.
This is what I tried without success:
var breakpoint = document.body.currentStyle.getPropertyValue('content');
Does anyone know how to do this?
Edit: After the BoltClock note, I now changed my css to this (one half-ton):
body:after { content: 'medium'; display: none; }
Before using the two, the content did not even appear in IE8, so it would have nothing to return. Unfortunately, I still cannot get IE8 to return content.
I am trying to do this:
if (style = document.body.currentStyle) { for (var prop in style) { if (prop === 'content') { alert(prop); } } }
I get nothing, but if I change the 'content' to another property, like 'backgroundColor' , it will warn something. Therefore, I think that although msdn lists the content as one of the available currentStyle properties http://msdn.microsoft.com/en-us/library/ie/ms535231%28v=vs.85%29.aspx , it does not actually return it if I do not do something else wrong.