LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-01-2003, 12:52 PM   #1
slightcrazed
Member
 
Registered: May 2003
Location: Lisbon Falls, Maine
Distribution: RH 8.0, 9.0, FC2 - 4, Slack 9.0 - 10.2, Knoppix 3.4 - 4.0, LFS,
Posts: 789

Rep: Reputation: 30
Javascript spell check


OK,
I have been 'volunteered' for a little project here at work. We have an HTML application that is our main customer database, but it has no in-built spell check feature. Management would like to spell check documentation that is entered into a customer's file. I have no direct access to the HTML application, so the only way I can interact with it is though the .hta file that loads the application. Here is my problem:

I have found a nifty little Javascript that will copy selected text from a web page, paste it into Word, run Word's built in spell check, and then paste the changes back into the original document. Code:

Code:
<HTML>
<HEAD>
<TITLE>NaviLink</TITLE>
<HTA:APPLICATION ID="htaNavLink" 
  APPLICATIONNAME="NavLink" 
  BORDER="thick"
  CAPTION="yes"
  SHOWINTASKBAR="yes"
  SINGLEINSTANCE="no"
  SYSMENU="yes"
  WINDOWSTATE="normal"
  NAVIGABLE="yes"
  SCROLL="yes"
  SELECTION="no"
  MAXIMIZEBUTTON="yes"
  MINIMIZEBUTTON="yes"
  INNERBORDER="no"
  CONTEXTMENU="yes">
<script language="JScript">

function spellcheck()
{oShell= new 
ActiveXObject("WScript.Shell");
oShell.SendKeys( "^c" ); // copy
oWord= new ActiveXObject("Word.Application");
oWord.Visible= true;
oWord.Documents.Add();
oWord.Selection.Paste();
oWord.ActiveDocument.CheckSpelling();
oWord.Selection.WholeStory();
oWord.Selection.Copy();
oWord.ActiveDocument.Close(0);
oWord.Quit();
var nRet= oShell.Popup( 
"Apply changes?\nClick OK to replace all selected text.",
0,
"Spell Check Complete",
33 );
if ( nRet == 1 ) {
oShell.SendKeys( "^v" ); // paste
}}
</script>
</HEAD>
<BODY STYLE=Margin:0px ONLOAD=LoadApp()>
<table border="0" width="100%"><tr>
<td><input type="button" id="BB" class="clsButton" value="SpellCheck"
onClick="spellcheck()"></td>
</table>
<IFRAME ID="fraApp" APPLICATION="Yes" STYLE="Width:100%;Height:100%;"></IFRAME>
<script language=vbScript>
	Sub LoadApp()
		window.moveTo 0, 0
		window.resizeTo 1025, 735
		document.all.fraApp.src = "http://comapny/program.htm" 
	End Sub
</script>
</BODY>
</HTML>
As you can see, the application is being loaded in an iframe. For some strange reason that is well beyond my very limited capabilities, the application in the iframe doesn't respond to the sendkeys command. So no text is being copied, and the spell check fails.

Any ideas on what I might be missing? I know that within the application pressing ctrl+c and ctrl+v work well enough for copy paste, but I don't know how to code this into the script.

I probably did a real bad job of explaining the problem, so let me know if I can clarify.

slight
 
Old 10-02-2003, 07:39 AM   #2
nephilim
Member
 
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
This is just a guess, but shouldn't you select something first, like

oShell.SendKeys( "^a" ); // select all
 
Old 10-02-2003, 10:05 AM   #3
slightcrazed
Member
 
Registered: May 2003
Location: Lisbon Falls, Maine
Distribution: RH 8.0, 9.0, FC2 - 4, Slack 9.0 - 10.2, Knoppix 3.4 - 4.0, LFS,
Posts: 789

Original Poster
Rep: Reputation: 30
I have tried select all via the sendkeys command, and also just by highlighting with the mouse, and neither works. It's as if the document in the <iframe></iframe> is oblivious to the command, like it's seperate from the rest of the document.

thanks for the suggestion though.

slight
 
Old 10-02-2003, 04:08 PM   #4
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
..... I have a spell-checker written in JavaScript I did for a project .... e-mail me if you want it. It does require
1.) JavaScript (duh!)
2.) server-side language (asp, php, etc.)
3.) database or flat files

if you have asp/perlscript and sql server you won't even need to change it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
No spell check in Openoffice t2701 Debian 14 07-03-2011 08:08 AM
Spell Check in Firefox mattp Linux - Software 2 10-09-2005 11:15 AM
Konqueror and Spell Check aldimeneira Linux - Software 1 08-30-2005 03:08 PM
spell check under opera??? bigjohn LQ Suggestions & Feedback 2 02-02-2003 12:51 AM
vi spell-check? jeri Linux - General 2 09-01-2001 03:41 PM


All times are GMT -5. The time now is 09:00 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration