sintax尝试和除了istruction [英] sintax for try and except istruction
问题描述
有没有像
一样的尝试.....
除了.....
is there an istruction like the
try .....
except.....
推荐答案
>尝试.....
> try .....
除了.....
您完成条款:
try {} catch(e){} finally {}
是的,它最近被添加到JavaScript和JScript中。
从未见过它在使用中但是在实际的脚本中。要么没有多大用处,要么有点执行错误,或者我不知道。
从使用它的人那里获得一些反馈会很棒。
You ment the clause:
try {} catch (e) {} finally{}
Yes, it has been relatively recently added to both JavaScript and JScript.
Never seen it in use yet though in actual scripts. Either no much use, or
some implementation errors, or I don''t know.
Would be great to get some feed-back from who ever used it.
2004年10月9日星期六10:44:35 GMT,SAN CAZIANO< al ********** @ tin.it>写道:
On Sat, 09 Oct 2004 10:44:35 GMT, SAN CAZIANO <al**********@tin.it> wrote:
有没有像
尝试.....
除了.....
is there an istruction like the
try .....
except.....
var e;
尝试{
//在这里执行导致异常的代码
>
} catch(e){
// e代表抛出的异常
}终于{
//代码总是执行,是否抛出异常
}
一个try语句没有'不需要捕获和最终条款,但
必须至少包含其中一个。
这是对语言的最新补充。像NN4这样的浏览器在遇到这些关键字时会出现
错误,因为它们是在
时间内保留的。 IE5,Netscape 6和Mozilla将支持try..catch。当Opera开始支持时,我不知道
。
您确定需要使用这些声明吗?
Mike
-
Michael Winter
替换.invalid与.uk通过电子邮件回复。
var e;
try {
// Execute exception-causing code here
} catch(e) {
// e represents the exception thrown
} finally {
// Code always executed, whether an exception was thrown or not
}
A try statement doesn''t require both of the catch and finally clauses, but
at least one of them must be included.
This is a fairly recent addition to the language. Browsers like NN4 will
error when encountering these keywords as they were reserved during that
time. IE5, Netscape 6 and Mozilla will support try..catch. I don''t know
when Opera began support.
Are you certain you need to use these statements?
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
使用它的一个原因,事实上我是因为这个原因使用它。
当您的页面加载时,在实际创建元素之前,您无法引用元素的id。现在
认为你已经创建了一个实际上是模板的页面。页面动态加载图像。如果图像是
大< div id =" oLImage ...>加载,但如果图像很小< div id =" oSImage ...>负载。你不知道
将要求哪个图像,因此将生成哪个div。一个或另一个,但不是两个将
。这是解决方案:
尝试{
//使用元素id =''oLImage'做某事'
}
catch {
//用元素id =''oSImage'做一些事情''
}
页面上没有脚本错误,但实际上当< div id =''oSImage''时出现错误....> (图像是
小)结果进入catch()。
-
George Hester >
__________________________________
" VK" < SC ********** @ yahoo.com>在留言新闻中写道:41 ********************* @ news.freenet.de ...
One reason why it is used and in fact I use it for this reason.
When your page loads you cannot refer to an element''s id until the element has actually been created. Now
consider you have made a page that is actually a template. The page dynamically loads an image. If the image is
large the <div id="oLImage...> loads but if the image is small <div id="oSImage ...> loads. You don''t know
which image is going to be requested and therefore which div will be made. One or the other but not both will
be made. Here''s the solution:
try{
// do something with element id=''oLImage''
}
catch{
//do something with element id=''oSImage''
}
No script errors on the page but in fact an error does occur when <div id=''oSImage''....> (the image is
small) results which goes to the catch().
--
George Hester
__________________________________
"VK" <sc**********@yahoo.com> wrote in message news:41*********************@news.freenet.de...
尝试.....
除了.....
try .....
except.....
你完成了这个条款:
try {} catch(e){} finally { }
是的,它最近都被添加到了JavaScript和JScript中。
在实际的脚本中,它从未见过它。要么没用多少,要么有些实现错误,或者我都不知道。
从使用它的人那里得到一些反馈会很棒。
You ment the clause:
try {} catch (e) {} finally{}
Yes, it has been relatively recently added to both JavaScript and JScript.
Never seen it in use yet though in actual scripts. Either no much use, or
some implementation errors, or I don''t know.
Would be great to get some feed-back from who ever used it.
这篇关于sintax尝试和除了istruction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!