当サイトはユーザー体験を改善するためのメンテナンスを実施中に機能が制限される予定です。記事を読んでもあなたの問題が解決せず質問をしたい場合は、Twitter の @FirefoxSupport、Reddit の /r/firefox で、サポートコミュニティが皆さんを助けようと待機しています。

Mozilla サポートの検索

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

詳しく学ぶ

このスレッドはアーカイブに保管されました。 必要であれば新たに質問してください。

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

  • 1 件の返信
  • 2 人がこの問題に困っています
  • 6 回表示
  • 最後の返信者: 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?

選ばれた解決策

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"';

この回答をすべて読む 👍 0

すべての返信 (1)

more options

選ばれた解決策

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"';