473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

trapping JS errors

i wrote this code that is meant to check if the client browser generates an
error when executing the blendtrans statement.
unfortunately it's not working as i wished.
this page is called check.asp and the site main page is called index.asp
all the site's pages will use the JS cookie to decide what script will have
to be used, the one using the blendtrans method or another one that simply
shows/hides the obj.
it's a mix of JS and ASP.
thanks to everyone for your help.

<% if request("js") = false or request.cookies("js") = false then %>
<% response.cookies("js") = false %>
<html>
<head>
<script language=javascript>
function go_on() {
redirect = eval(self.location="index.asp");
return true;
}
</script>
</head>
<body onLoad="go_on()">
</body>
</html>
<% else %>
<html>
<head>
<title="N-Side - Checking browser">
<link href="Gatherer.css" rel="stylesheet" type="text/css">
<script language=javascript>
function fadein(obj) {
myObj = eval(obj);
window.onError = noJS();
myObj.filters.blendTrans.apply();
myObj.style.visibility = "visible";
myObj.filters.blendTrans.play();
redirect = eval(self.location='index.asp');
return true;
}
function noJS() {
redirect = eval(self.location='check.asp?js=false'>;
return true;
}
</script>
</head>
<body onLoad="fadein(test)" onError="noJS()">
<div id="test" style="visibility: hidden;">
</body>
<% end if %>
Jul 20 '05 #1
1 3310
"CAFxX" <ca***@n-side.it> writes:
i wrote this code that is meant to check if the client browser generates an
error when executing the blendtrans statement.
How is it supposed to check that?
unfortunately it's not working as i wished.
What did you wish? What really happened?
this page is called check.asp and the site main page is called index.asp
all the site's pages will use the JS cookie to decide what script will have
to be used, the one using the blendtrans method or another one that simply
shows/hides the obj.
it's a mix of JS and ASP.
You could just have posted the HTML, as posted to the client. The
error should be in that part. In this case, the ASP part is so small
and unintrusive that it is not a problem
<script language=javascript>
<script type="text/javascript">
The type attribute is mandatory and the language attribute is deprecated
in HTML 4.
function go_on() {
redirect = eval(self.location="index.asp");
This will probably redirect the page before the error appears, but
it is an error. You don't need eval for anything on this page, and
probably not on any other page you make.
Just use:
self.location.href="index.asp";

If the expression inside eval hadn't redirected the page, it would
evaluate to "index.asp", which you then try to evaluate as a
Javascript expression. There is no object called "index", so that gives
an error.
return true;
You won't get to return either, the page is already gone.
} <script language=javascript>
Again type="text/javascript"
function fadein(obj) {
myObj = eval(obj);
You don't need eval here. The value of "obj" is an object, and using
eval on that just gives itself again. If obj had been a string, it
would probably still not be what you wanted.
window.onError = noJS();
The on-event handlers are not subcapitalized in Javascript.
You wrote onError in the HTML tag, but that is because HTML is not
case sensitive. Javascript is.

You don't want to call the noJS function now, just assign it as a
handler.

window.onerror = noJS;

I am not familiar with the onerror handler for windows, so I'll assume
you know what you are doing. Ditto for blendTrans.
myObj.filters.blendTrans.apply();
myObj.style.visibility = "visible";
myObj.filters.blendTrans.play();
redirect = eval(self.location='index.asp');
Again:
self.location.href="index.asp";
return true;
}
function noJS() {
redirect = eval(self.location='check.asp?js=false'>; and again :)
self.location.href="check.asp?js=false";
return true;
} <body onLoad="fadein(test)" onError="noJS()">
This will only work in very few browsers, those that make a
global variable, "test", referring to the element with id="test".

<body onload="fadein(document.getElementById('test'))" onerror="noJS()">
<div id="test" style="visibility: hidden;">


Good luck
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

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

Similar topics

6
by: Eitan | last post by:
Hello, I need an example of "Trapping Errors" in ASP (not .net) Thanks :)
3
by: JP | last post by:
I need to be able to trap errors at the application level. I added this code to the Global.asax file. The code I wrote is supposed to get the last error that was generated and write to the event...
3
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records...
21
by: Neil | last post by:
Is there a way to trap an error generated in another app that is controlled via automation? I have an Access 2000 app that opens Word 2000 and proceeds to open a series of documents and, in each...
3
by: windandwaves | last post by:
Hi Gurus Does anyone know how I set the error trapping to option 2 in visual basic. I know that you can go to tools, options and then choose on unhandled errors only, but is there a VB command...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
2
by: Fred Nelson | last post by:
I'm devloping a VB.NET web application and I'm having a problem with trapping errors and logging the cause of them. When an unexpected error occurs I want to write it to a file - or e-mail it to...
2
by: Captain Nemo | last post by:
I'm still using Office 2000 myself, but some of my clients have Office 2003. I've recently added a piece of code to create an instance of Word, open a document, fill in the blanks and become...
9
by: 47computers | last post by:
Pretty new to PHP, I recently started learning about error trapping. As of right now, I include the following into a page in my website: -------BEGIN PASTE-------- error_reporting(E_ERROR |...
1
by: asearle | last post by:
I am a bit new to Perl and am having trouble trapping errors in script ... However, I think that it is just simple syntax issues and hope that someone can point me towards a good HOWTO which might...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.