Ce site disposera de fonctionnalités limitées pendant que nous effectuons des opérations de maintenance en vue de vous proposer un meilleur service. Si un article ne règle pas votre problème et que vous souhaitez poser une question, notre communauté d’assistance est prête à vous répondre via @FirefoxSupport sur Twitter, et /r/firefox sur Reddit.

Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

En savoir plus

Javascript command window.getComputedStyle(document.body, ':after').getPropertyValue('content') returns content with extra double quotes

  • 1 réponse
  • 2 ont ce problème
  • 6 vues
  • Dernière réponse par cor-el

more options

When I use in my css: body:after { content: "mobile"; display: none; } And check this with javascript with the command: var size = window.getComputedStyle(document.body, ':after').getPropertyValue('content');

I get in firefox (v 23.0.1 mac) returned the string ""mobile"" with doubled quotes as return and therefore the check if size =="mobile" returns false. In safari the value returned "mobile" without the doubles quotes. How come?

When I use in my css: body:after { content: "mobile"; display: none; } And check this with javascript with the command: var size = window.getComputedStyle(document.body, ':after').getPropertyValue('content'); I get in firefox (v 23.0.1 mac) returned the string ""mobile"" with doubled quotes as return and therefore the check if size =="mobile" returns false. In safari the value returned "mobile" without the doubles quotes. How come?

Solution choisie

What you get is a string that represents of what you specified in content.

A content specification can include other things like a counter: body:after { content: "topics[" counter(topics) "]"; }

size = window.getComputedStyle(document.body, ':after').content would give: "topics[" counter(topics) "]"
So you need to test for the exact text of the content: size=='"mobile"';

Lire cette réponse dans son contexte 👍 0

Toutes les réponses (1)

more options

Solution choisie

What you get is a string that represents of what you specified in content.

A content specification can include other things like a counter: body:after { content: "topics[" counter(topics) "]"; }

size = window.getComputedStyle(document.body, ':after').content would give: "topics[" counter(topics) "]"
So you need to test for the exact text of the content: size=='"mobile"';