Click to See Complete Forum and Search --> : JS Scripting Error...Can You Help?


kwilliams
09-24-2003, 04:52 PM
I'm getting the following error message when it comes to a simple script:

Internet Explorer Script Error
An error occurred in the script on this page.
Line: 200
Char: 38
Error: Object expected OR Object doesn't support property or method
Code: 0
URL: http://dgitsrv1/Releases/Commission/RTE_Files/richedit.html

Do you want to continue running scripts on this page?


This is the Javascript that's giving the error:

function cancel()
{
var button = confirm("If you are sure that you want to quit, click 'OK'. Otherwise click 'CANCEL'.")
if (button == true)
{
javascript:history.back()
}}


The error message is referencing the line about going back a page if the 'OK' button is pressed. It works fine if 'CANCEL'

is pressed. I've also tried changing javascript:history.back() to history.go(-1), but it still doesn't work. I've used this

function on several other parts of the site with success, so I don't know why it's not working properly. Any & all help is

appreciated.

KWilliams

Khalid Ali
09-25-2003, 12:17 AM
do this ,it will work

if (button){
history.go(-1);
}

etard
09-25-2003, 12:27 AM
hmm. I thought the error might be syntax error:

you have

java script:history.back()

it should be

javascript:history.go(-1)

Notice no space between javascript - your way throws and error but javascript does not. this way works as I use it ALL the time.

Khalid Ali
09-25-2003, 08:13 AM
Originally posted by etard
hmm. I thought the error might be syntax error:


This forums form processor splits javascript in to 2 words,in most of the cases when members post their code thats not th eproblem,however,in few cases if they copy it from this forum,then it could be a ligitimate error.

kwilliams
09-25-2003, 08:16 AM
Khalid & etard,

You are correct Khalid...as I did post it as one workd, not two. I've tried your suggestion etard, but it still gave me an error message. That's why it's confusing. It's worked fine before, but now I'm getting this message on a page that I have a new Rich text Editor on. I'm completely lost on this one.

KWilliams

Khalid Ali
09-25-2003, 08:33 AM
The tiny bit of a piece I posted, does work, and if you tried that and it does not work then the error might be somewehre else..you will need tp post the link to the pages where you have implemented this code.

kwilliams
09-25-2003, 09:10 AM
Hi Khalid,

I've created a page on my external server that shows the RTE with the "CANCEL" button I'm referencing at: http://www.douglas-county.com/Example/minutes_add.asp

As you'll see, when you click the "CANCEL" button, the "cancel()" function will be called properly. When you click the "Cancel" button from the confirm box, it will do the correct action. But if you select the "OK" button from the confirm box, it will give you an IE Scripting Error. Let me know if it does the same for you, and if you come up with any solutions. Thanks Khalid.

KWilliams

Khalid Ali
09-25-2003, 09:34 AM
I have taken a look at the page,it will be niceif you could let me know which are the files that I need to look at rather then going through an array of JS src files..

:D

kwilliams
09-25-2003, 09:46 AM
Here's the page that is the source for the RTE:
http://www.douglas-county.com/Example/RTE_files/richedit.html

This is the "cancel()" function that it references:
<SCRIPT language="JavaScript" src="cancel.js"></SCRIPT>

This is the code I have in that "cancel()" function:
function cancel()
{
var button = confirm("If you are sure that you want to quit, click 'OK'. Otherwise click 'CANCEL'.")
if (button){
history.go(-1);
}}

And this is the section of richedit.html that displays the button, and calls the function with an onClick event:
<img id="btnCancel" onclick="cancel()" alt="Cancel" src="@{icon_cancel}" align="absMiddle" width="58" height="20">

Let me know if you see anything obvious. Thanks.

KWilliams[QUOTE] ff