I want to make a function that creates a list of the words that are misspelled inside a textarea. Is there a way to get the words that are underlined in red for being misspelled according to the default dictionary/spellchecker?
I know I could do it with a dictionary of 'my own' and check with that, but I'm aiming to do it using the automatic spellchecker textboxes have. Thanks in advance.
It's hard to prove a negative, but I don't think user agents make that information available to your code. There's nothing in the HTMLTextAreaElement
or Text
interfaces for it, for instance, nor on Document
or Navigator
. Nothing in the description of the spellcheck
attribute mentions it. The HTML spec's Spelling and grammar checking section doesn't mention anything.
There may be hope on the horizon though. CSS is adding the ::spelling-error
pseudo class, although there isn't any support for it in browsers yet. Although that wouldn't help you do what you're doing, it indicates that there is at least some interest in allowing pages to interact with this information in some way. So it may happen someday.