473,725 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JavaScript error - - please help!

There is a spell checker function which is written in VB Script. The
function works well when tested seperately. But when the function is
called from Java Script, the function shows an Error saying " A run
time error has occured. Do you wish to debug? Line :0 , Object
Expected". I just know that it is a Java Script error.
Any suggestions on how to resolve this problem ? What could be the
possible reasons for this error message?

Here is the spell checker function: The way this function is called
from JavaScript is like this :

<span style="float:ri ght;text-align:right;wid th:50%"><a
href="javascrip t:SpellCheck(fr mMain.taComment .innerText)">Sp elling
Checker</a></span>

<%
function SpellCheck(strC omments)
dim msg
dim objWord, objDocument, NumberofWords, NumberofErrors
Set objWord = CreateObject("W ord.Application ")
Set objDocument = objWord.Documen ts.Add
objDocument.Con tent = strComments

NumberOfWords = objDocument.Wor ds.count
NumberOfErrors = objDocument.Spe llingErrors.Cou nt

If NumberOfErrors = 0 Then
Response.Write "No Spelling Errors" & "<br>"
'NO spelling errors...
Else
'loop through each word in the document
i=1
while i < NumberOfWords
if objDocument.Wor ds(i).SpellingE rrors.Count > 0 then
msg = "Misspelled : " & objDocument.Wor ds(i).text & vblf &
"<br>"
'Yes, there are errors, see if there are any suggestions
for xSuggestions = 1 to
objDocument.Wor ds(i).GetSpelli ngSuggestions.c ount
if xSuggestions = 1 then
msg = msg & vblf & "Suggestion s: " &
objDocument.Wor ds(i).GetSpelli ngSuggestions.I tem(1).Name
else
msg = msg & vblf & " " &
objDocument.Wor ds(i).GetSpelli ngSuggestions.I tem(xSuggestion s).Name
end if
next
Response.Write msg
else
end if
i = i + 1
wend
end If
objDocument.sav eas "c:\t.doc"
objDocument.clo se false
set objDocument = nothing
objWord.quit false
Response.Write "Spell check is finished!"
end function
%>
Jul 23 '05 #1
1 1670
questionr wrote:
There is a spell checker function which is written in VB Script. The
function works well when tested seperately. But when the function is
called from Java Script, the function shows an Error saying " A run
time error has occured. Do you wish to debug? Line :0 , Object
Expected". I just know that it is a Java Script error.
Any suggestions on how to resolve this problem ? What could be the
possible reasons for this error message?

Here is the spell checker function: The way this function is called
from JavaScript is like this :

<span style="float:ri ght;text-align:right;wid th:50%"><a
href="javascrip t:SpellCheck(fr mMain.taComment .innerText)">Sp elling
Checker</a></span>

<%
function SpellCheck(strC omments)
dim msg
dim objWord, objDocument, NumberofWords, NumberofErrors
Set objWord = CreateObject("W ord.Application ")
Set objDocument = objWord.Documen ts.Add
objDocument.Con tent = strComments

NumberOfWords = objDocument.Wor ds.count
NumberOfErrors = objDocument.Spe llingErrors.Cou nt

If NumberOfErrors = 0 Then
Response.Write "No Spelling Errors" & "<br>"
'NO spelling errors...
Else
'loop through each word in the document
i=1
while i < NumberOfWords
if objDocument.Wor ds(i).SpellingE rrors.Count > 0 then
msg = "Misspelled : " & objDocument.Wor ds(i).text & vblf &
"<br>"
'Yes, there are errors, see if there are any suggestions
for xSuggestions = 1 to
objDocument.Wor ds(i).GetSpelli ngSuggestions.c ount
if xSuggestions = 1 then
msg = msg & vblf & "Suggestion s: " &
objDocument.Wor ds(i).GetSpelli ngSuggestions.I tem(1).Name
else
msg = msg & vblf & " " &
objDocument.Wor ds(i).GetSpelli ngSuggestions.I tem(xSuggestion s).Name
end if
next
Response.Write msg
else
end if
i = i + 1
wend
end If
objDocument.sav eas "c:\t.doc"
objDocument.clo se false
set objDocument = nothing
objWord.quit false
Response.Write "Spell check is finished!"
end function
%>


You are trying to call a function defined on the server from client-side
JavaScript. This of course, will not work. When a request for this page
arrives at your server, IIS loads the .asp page, parses and executes
anything between <% and %> and sends the resulting *HTML* (and possibly
client-side JavaScript) to your client.

Once the document is at the client, the only thing client-side
JavaScript has access to is client-side code. As far as the server is
concerned, the client is gone, done, finished. The server-side code has
been parsed, executed and the result returned to the client, that
function is simply not available to client-side JavaScript (although it
would be available to code that might need it while that page is being
executed by IIS).

There are a variety of ways of calling server-side code from the client,
but given the fact that you haven't yet grasped the concept of
server/client separation, it would probably be fairly confusing to bring
them up and how they could be used to implement a client-side
spellchecker.

--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2205
by: TeknoCat | last post by:
Hey everyone, I may be repeating myself here, but if someone sent a reply then I missed it, and I can't get Outlook Express to download any messages more than 2 days old. Anyway, I'm having a problem with some new pages I am creating for the Web site at www.weaverdevore.ca and I am wondering if anyone here might be able to help. Here is a full description of the problem:
1
1987
by: JumpingOffPlace | last post by:
Hi, I'm hoping that the wealth of knowledge here can stop me from spinning my wheels on this syntax error for hours. :) Below is the code, and the error I am recieving.... Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="/WEB-INF/tag-lib/struts-html-el.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/tag-lib/struts-bean.tld" prefix="bean" %>
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.