hello!
I’ve downloaded a sample javascript code but I wanted to add check grammar/spelling feature. However, Im having problems with it.
Although I have a code that opens the check grammar & spelling, however it still needs some fixing. please help me.
bug 1:whenever I click the spelling button, the html tags are also displayed in the check grammar & spelling window. but
if I change the innerHTML to innerText, after checking the spelling, the format was lost.
bug 2: if the check grammar & spelling window was visible and I clicked the cancel button, the contents of my text area was deleted.
the sample text that I used is having a table & bulleted list with wrong spelling. please help me improve my code.
heres the part where the code revision is required:
// Spelling
else if (id == “spelling”)
{
document.getElementById(“wysiwyg” + n).contentWindow.focus();
objWord = new ActiveXObject(“Word.Application”)
objWord.WindowState = 2
objWord.Documents.Add()
objWord.Selection.text=document.getElementById(“wysiwyg” + n).contentWindow.document.body.innerText.replace(/^s+/,””).replace(/s+$/,””)
objWord.ActiveDocument.CheckGrammar()
objWord.Visible=true;
objWord.Activate();
document.getElementById(“wysiwyg” + n).contentWindow.document.body.innerHTML= objWord.Selection.text;
objWord.ActiveDocument.Close(0);
objWord.Quit();
objWord = null
alert(“Spell Check Complete”);
if (top.opener || parent.window.dialogArguments)
{
self.close();
}
}
Thank you