I am applying an :after
pseudo element to the body displaying the name of my media query breakpoint like so:
body::after {
content: 'medium';
display: none;
}
The reason for doing this can be found here: http://adactio.com/journal/5429/
I want to get the content value of :after
using javascript in IE8.
This is how i am doing it for other browsers:
var breakpoint = window.getComputedStyle(document.body, ':after').getPropertyValue('content');
But IE8 does not support getComputedStyle()
, i know it supports currentStyle
instead, but after a bit of trying i was unable to use it correctly.
This is the kind of thing i was trying with no success:
var breakpoint = document.body.currentStyle.getPropertyValue('content');
Anybody know how to do this?
Edit: After BoltClock's note i have now changed my css to this (one semi colon):
body:after {
content: 'medium';
display: none;
}
Before using two the content was not even appearing in IE8, so it would have had nothing to return. Unfortunately i still can't get IE8 to return the content.
I am trying this:
if (style = document.body.currentStyle) {
for (var prop in style) {
if (prop === 'content') {
alert(prop);
}
}
}
I get nothing, but if i change 'content'
to some other property like 'backgroundColor'
it will alert something. So i'm thinking that even though msdn lists content as one of the available properties of currentStyle
http://msdn.microsoft.com/en-us/library/ie/ms535231%28v=vs.85%29.aspx it does not actually return it, unless i'm doing something else wrong.