Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I capture :after content in IE8?
    primarykey
    data
    text
    <p>I am applying an <code>:after</code> pseudo element to the body displaying the name of my media query breakpoint like so:</p> <pre class="lang-css prettyprint-override"><code>body::after { content: 'medium'; display: none; } </code></pre> <p>The reason for doing this can be found here: <a href="http://adactio.com/journal/5429/" rel="nofollow">http://adactio.com/journal/5429/</a></p> <p>I want to get the content value of <code>:after</code> using javascript in IE8.</p> <p>This is how i am doing it for other browsers:</p> <pre><code>var breakpoint = window.getComputedStyle(document.body, ':after').getPropertyValue('content'); </code></pre> <p>But IE8 does not support <code>getComputedStyle()</code>, i know it supports <code>currentStyle</code> instead, but after a bit of trying i was unable to use it correctly.</p> <p>This is the kind of thing i was trying with no success:</p> <pre><code>var breakpoint = document.body.currentStyle.getPropertyValue('content'); </code></pre> <p>Anybody know how to do this?</p> <p><strong>Edit:</strong> After BoltClock's note i have now changed my css to this (one semi colon):</p> <pre class="lang-css prettyprint-override"><code>body:after { content: 'medium'; display: none; } </code></pre> <p>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.</p> <p>I am trying this:</p> <pre><code>if (style = document.body.currentStyle) { for (var prop in style) { if (prop === 'content') { alert(prop); } } } </code></pre> <p>I get nothing, but if i change <code>'content'</code> to some other property like <code>'backgroundColor'</code> it will alert something. So i'm thinking that even though msdn lists content as one of the available properties of <code>currentStyle</code> <a href="http://msdn.microsoft.com/en-us/library/ie/ms535231%28v=vs.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ie/ms535231%28v=vs.85%29.aspx</a> it does not actually return it, unless i'm doing something else wrong.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload