473,405 Members | 2,338 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,405 software developers and data experts.

check for catch try support in js

Mike Kypriotis
I have been trying to write a script as error-proofe as possible (check for DOM support, handling events according to IE/WC3 model) and the only thing I do not know how to check is the try/catch construct. For PC browsers I know above which version for each it is supported (plus I believe that its also fully supported in ECMAScript version 3 right?) but I wanna it to run and in other browsers (mobile phones etc.) where I cannot be sure what they are capable of handling and thus need a check proccedure to define if they support catch-try.
Dec 4 '11 #1
3 1659
Dormilich
8,658 Expert Mod 8TB
the support of try … catch is depending on the use JS engine (webkit, SpiderMonkey, V8, etc.) the last browser I know that didn’t support it was IE4!

so I would assume that every mobile browser supports it
Dec 4 '11 #2
Hmmm...true but still a test would be nice, never know what each browser can support, read from another thread
"If you test the 'typeof' one of the Error classes that is supported in the version 3 of EcmaScript you can have high confidence that try-catch is also supported. The return value will be 'function'. A return value of Object means the null object, and no support. For instance:
Expand|Select|Wrap|Line Numbers
  1. if(typeof(window.TypeError)=='function'){
  2. go ahead and include try catch code.
  3. }
"
what do u think?
P.S. by JS engine u are referring to the ECMAscript edition (thus the core language) supported?
Dec 5 '11 #3
Dormilich
8,658 Expert Mod 8TB
by JS engine I mean the implementation code of ECMAScript the browser vendors used.

but my point is, if you need to check for the most basic language features, you’re overdoing things. at some point you can simply say "if even that’s not supported, my other code won’t run as well" otherwise you end up writing double and triple code.

PS. as a demo, try to write a capturing (emulating) event handler for IE6-8.
Dec 5 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mvdevnull | last post by:
hey all currently i use the following piece of code to check if the string passed to me can be converted to base64, it is not very efficient and bad, can someone please suggest another of doing...
15
by: Robert Mark Bram | last post by:
Hi All! Problem I began with: Netscape/Opera supports hover for different elements, IE only supports hover for <a> and I want to use hover for <td class="menu"> I then found a fix using some...
11
by: kaeli | last post by:
Hey all, I'd like to start using the try/catch construct in some scripts. Older browsers don't support this. What's the best way to test for support for this construct so it doesn't kill...
7
by: adnanx82 | last post by:
Hi, Does anyone know how a script can detect whether exception handling using try/catch blocks is supported in the browser, so that it can use them to perform better error handling, and a syntax...
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
0
by: Roman | last post by:
I'm trying to create the form which would allow data entry to the Client table, as well as modification and deletion of existing data rows. For some reason the DataGrid part of functionality stops...
4
by: DavideR | last post by:
I have converted a large vb6 program with an add-in that for every routine gimme the error handling: the add-in adds one line on the head of the routine "if myerrhandle then ON ERROR GOTO...
25
by: pamelafluente | last post by:
Hi Guys, I have the following HTML code which is doing a GET to a page, say MyUrl.aspx : <body> <form name="form1" method="get" action="MyUrl.aspx" id="form1"> <input type="hidden"...
3
by: petermichaux | last post by:
Hi, I'm trying to do the right thing. I currently have a page that doesn't have any JavaScript and the page works. The page works with CSS on or off. Now I would like to add some JavaScript to...
173
by: Marty James | last post by:
Howdy, I was reflecting recently on malloc. Obviously, for tiny allocations like 20 bytes to strcpy a filename or something, there's no point putting in a check on the return value of malloc....
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.