Button to spell check a web-page

311 views
Skip to first unread message

anatoly techtonik

unread,
Mar 26, 2011, 9:11:39 PM3/26/11
to Chromium-discuss
Hi.

I know Chrome has builtin spellchecker, but am I right that it works
only for forms? Is it possible to create button that allows to check
spelling of current web-page contents or selected part of it?

Thanks.

PhistucK

unread,
Mar 27, 2011, 2:46:06 AM3/27/11
to tech...@gmail.com, Chromium-discuss
No API exists for that.
Although, it might work if you turn the desired text into a textarea with the same content.

PhistucK




--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
   http://groups.google.com/a/chromium.org/group/chromium-discuss

JohnLBevan

unread,
Mar 27, 2011, 8:46:00 AM3/27/11
to Chromium-discuss
Pasting something along the lines of the following into your address
bar should copy the text from the page into a textarea, after which
spell check should work - not an ideal solution, but hopefully a
helpful hack?

javascript:var ta=document.createElement('textarea');var
s=document.createAttribute('style');s.nodeValue='width:100%;height:
400em;';ta.setAttributeNode(s);ta.appendChild(document.createTextNode(document.body.innerText));document.body.appendChild(ta);

Cheers,

JB

On Mar 27, 6:46 am, PhistucK <phist...@gmail.com> wrote:
> No API exists for that.
> Although, it might work if you turn the desired text into a textarea with
> the same content.
>
> ☆*PhistucK*
>
> On Sun, Mar 27, 2011 at 03:11, anatoly techtonik <techto...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hi.
>
> > I know Chrome has builtin spellchecker, but am I right that it works
> > only for forms? Is it possible to create button that allows to check
> > spelling of current web-page contents or selected part of it?
>
> > Thanks.
>
> > --
> > Chromium Discussion mailing list: chromium-disc...@chromium.org

Caleb Eggensperger

unread,
Mar 27, 2011, 10:08:20 PM3/27/11
to johnl...@gmail.com, Chromium-discuss
I'm not able to get your script to work (not sure why) but I thought
I'd point out long standing bug/feature crbug.com/6424, which is that
in some situations (such as text pasted into a textarea) spell
checking won't immediately turn on; it will, in fact, only work when
the cursor has been in or next to the misspelled word in question.
This may apply to the method you are using here.

> Chromium Discussion mailing list: chromium...@chromium.org


> View archives, change email options, or unsubscribe:
>    http://groups.google.com/a/chromium.org/group/chromium-discuss
>

--
Caleb Eggensperger
www.calebegg.com

JohnLBevan

unread,
Mar 28, 2011, 8:20:53 AM3/28/11
to Chromium-discuss
Thanks Caleb - yes, looks like that is a problem. . . maybe there's
some way to get the script to send the cursor over all text in the
text area (like a js version of vbs' sendkeys statement)? I'll look
into it tonight.

With regards to the script, it looks like a space got into, making
document docum ent. Reposting below.

javascript:var ta=document.createElement('textarea');var
s=document.createAttribute('style');s.nodeValue='width:100%;height:
400em;';ta.setAttributeNode(s);ta.appendChild(document.createTextNode(document.body.innerText));document.body.appendChild(ta);

Thanks again,

JB

On Mar 28, 3:08 am, Caleb Eggensperger <caleb...@gmail.com> wrote:
> I'm not able to get your script to work (not sure why) but I thought
> I'd point out long standing bug/feature crbug.com/6424, which is that
> in some situations (such as text pasted into a textarea) spell
> checking won't immediately turn on; it will, in fact, only work when
> the cursor has been in or next to the misspelled word in question.
> This may apply to the method you are using here.
>
>
>
>
>
>
>
>
>
> On Sun, Mar 27, 2011 at 07:46, JohnLBevan <johnlbe...@gmail.com> wrote:
> > Pasting something along the lines of the following into your address
> > bar should copy the text from the page into a textarea, after which
> > spell check should work - not an ideal solution, but hopefully a
> > helpful hack?
>
> > javascript:var ta=document.createElement('textarea');var
> > s=document.createAttribute('style');s.nodeValue='width:100%;height:
> > 400em;';ta.setAttributeNode(s);ta.appendChild(document.createTextNode(docum ent.body.innerText));document.body.appendChild(ta);
>
> > Cheers,
>
> > JB
>
> > On Mar 27, 6:46 am, PhistucK <phist...@gmail.com> wrote:
> >> No API exists for that.
> >> Although, it might work if you turn the desired text into a textarea with
> >> the same content.
>
> >> ☆*PhistucK*
>
> >> On Sun, Mar 27, 2011 at 03:11, anatoly techtonik <techto...@gmail.com>wrote:
>
> >> > Hi.
>
> >> > I know Chrome has builtin spellchecker, but am I right that it works
> >> > only for forms? Is it possible to create button that allows to check
> >> > spelling of current web-page contents or selected part of it?
>
> >> > Thanks.
>
> >> > --
> >> > Chromium Discussion mailing list: chromium-disc...@chromium.org
> >> > View archives, change email options, or unsubscribe:
> >> >    http://groups.google.com/a/chromium.org/group/chromium-discuss
>
> > --
> > Chromium Discussion mailing list: chromium-disc...@chromium.org
> > View archives, change email options, or unsubscribe:
> >    http://groups.google.com/a/chromium.org/group/chromium-discuss
>
> --
> Caleb Eggenspergerwww.calebegg.com

JohnLBevan

unread,
Mar 28, 2011, 4:12:31 PM3/28/11
to Chromium-discuss
Done & it seems to work! :)

javascript:var ta=document.createElement('textarea'); var
s=document.createAttribute('style'); s.nodeValue='width:100%;height:
400em;'; ta.setAttributeNode(s);
ta.appendChild(document.createTextNode(document.body.innerText));
document.body.appendChild(ta); ta.focus(); for(var
i=1;i<=ta.value.length;i++)ta.setSelectionRange(i,i);

(check for unwanted spaces - they seem to get put in after posting!)

More readable version:
javascript:

var ta=document.createElement('textarea');

var s=document.createAttribute('style');
s.nodeValue='width:100%;height:400em;';
ta.setAttributeNode(s);

ta.appendChild(document.createTextNode(document.body.innerText));

document.body.appendChild(ta);

ta.focus();
for(var i=1;i<=ta.value.length;i++)
ta.setSelectionRange(i,i);



On Mar 28, 1:20 pm, JohnLBevan <johnlbe...@gmail.com> wrote:
> Thanks Caleb - yes, looks like that is a problem. . . maybe there's
> some way to get the script to send the cursor over all text in the
> text area (like a js version of vbs' sendkeys statement)?  I'll look
> into it tonight.
>
> With regards to the script, it looks like a space got into, making
> document docum ent.  Reposting below.
>
> javascript:var ta=document.createElement('textarea');var
> s=document.createAttribute('style');s.nodeValue='width:100%;height:
> 400em;';ta.setAttributeNode(s);ta.appendChild(document.createTextNode(docum ent.body.innerText));document.body.appendChild(ta);
Reply all
Reply to author
Forward
0 new messages