getCommandValue is not working in firefox
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.
Soluție aleasă
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).
Citește acest răspuns în context 👍 0Toate răspunsurile (10)
That function is part of the Midas text editor that allows to edit text when designmode is enabled.
See:
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).
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?
There is a test file that Mozilla uses to test this feature:
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?
Modificat în
Soluție aleasă
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).
Thanks a lot,
Here's a very simple sample page:
http://jeffersonscher.com/forumshots/range-computedstyle.html
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
Modificat în
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:
- selection object - createRange
- TextRange object - queryCommandValue ? (queryCommandValue method)
- currentStyle object (applies to elements, comparable to getComputedStyle)