為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

getCommandValue is not working in firefox

more options

Hello,

queryCommandValue method in javascript used to get CSS Format of selected text. Though it shows support for Mozilla Firefox, it is not working in it. Refer Link :http://help.dottoro.com/ljqhsrpe.php

Thanks.

Hello, '''queryCommandValue '''method in javascript used to get CSS Format of selected text. Though it shows support for Mozilla Firefox, it is not working in it. Refer Link :http://help.dottoro.com/ljqhsrpe.php Thanks.

被選擇的解決方法

In that case, your bold text would be in its own "node":


<div><b>Hello</b> world to sample application</div>

I'll see whether I can create a demo page (not for a while, busy day).

從原來的回覆中察看解決方案 👍 0

所有回覆 (10)

more options

That function is part of the Midas text editor that allows to edit text when designmode is enabled.

See:

more options

You might able to use getComputedStyle() instead. See https://developer.mozilla.org/en-US/docs/DOM/window.getComputedStyle

That method operates on an element; I don't think it supports a range directly. You probably need to check the range's startContainer or endContainer (or both if they are different; hopefully not).

more options

Thanks a lot for a quick reply. document.queryCommandValue method link is not working. Will you please provide me a better example which can explain this?

more options

There is a test file that Mozilla uses to test this feature:

more options

Basically, I want style of selected text. Suppose, I have a full text "Hello world to sample application" placed in div. Then I made a word "Hello" in bold. I want to retrieve style of word "Hello" word and not of whole div. How to do this by using getComputedStyle or getCommandValue? Will you post whole html page snippet to do this?

由 nilophar 於 修改

more options

選擇的解決方法

In that case, your bold text would be in its own "node":


<div><b>Hello</b> world to sample application</div>

I'll see whether I can create a demo page (not for a while, busy day).

more options

Thanks a lot,

more options
more options

Hello jscher, The example provided by you is just awesome. Thanks a lot for your quick help. The example works well in Firefox,chrome and safari but not working with IE. What to do?

You and this forum helps me a lot. Keep it on...!!!

Thanks, Nilophar

由 nilophar 於 修改

more options

IE has a very different way of working with ranges, and I'm not sure you would use the same approach. Check out these articles, which might be similar to your original code: