AjavaScripterroroccurredinthemainprocess - 爱问答

(爱问答)

AjavaScripterroroccurredinthemainprocess

A javaScript error occurred in the main process

安装软件出现这个提示,请问如何解决

A javaScript error occurred in the main process


javascript 错误处理的几种方法1.使用window.onerror指定错误处理函数。 当有错误的时候,onerror会被callback。 当某个javaScript block中有多个script错误时,第一个错误触发后(回调callback),当前javascript block后面的script会被自动Drop忽略掉,不被执行。 如: 代码如下:<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test</title> <script type="text/javascript"> window.onerror = function(message, url, line) { alert("Error. Message:"+ message +" Url:" + url + " Line:" + line) return true; } </script> </head> <body> <script type="text/javascript"> test(); test(); test(); test(); </script> <script type="text/javascript"> test(); test(); test(); test(); </script> </body> </html>在上面的例子中只会有每一个block中的第一个test();产生error。触发window.onerror回调,后面的javascript会被忽略掉。img 也支持 onerror < img src="pic.gif" onerror = "javascript:alert("An error occurred.");"/>。onerror 是浏览器支持的对象。由浏览器决定是否可以使用,不是DOM标准。 2.使用javascript中的try catch throw处理异常。 javascript支持了try catch throw,javascript中定义的异常: (1)EvalError: An error occurs in the eval() function. (2)RangeError: A number value is greater then or less then the number that can be represented in javascript(Number.MAX_VALUE and Number.MIN_VAKUE). (3)ReferenceError: An illegal reference is used. (4)SyntaxError: A syntax error occus inside of an eval() function call. All other syntax error are reorted by the browser and cannot be handled with a try...catch statement. (5)TypeError. A variables type is unexpected. 6.URIError. An error ocuurs in the encodeURI() or the decodeURI() function. 如:  代码如下:<script type="text/javascript"> function CreateError() { throw new Error("Created error by custom."); } try { //throw a error from a function just want to see the call stack in firefox. CreateError(); } catch(error) { var errorMsg = ("Message: " + error.message + " "); if(typeof(error.stack)!=undefined) { //FF errorMsg += ("Line Number: " + error.lineNumber + " "); errorMsg += ("File Name: " + error.fileName + " "); errorMsg += ("Stack Trace: " + error.stack + " "); } else { //IE errorMsg += ("Description: " + error.description + " "); errorMsg += ("Number: " + error.number + " "); } alert(errorMsg); } finally { //alert("End try catch.message from finally block."); } </script> Error.message是IE和firefox都支持的属性。 IE支持description 和 number属性。 FF支持fileName lineNumber 和 stack 属性。 由于javascript是弱类型的语言。 所以在catch部分只能catch一次,不能像C#这样的语言可以写多个catch,catch不同类型的exception。 但是可以用 instanceof ErrorType的方式实现类似的功能。 如: 代码如下:<script type="text/javascript"> try { //Syntax Error //eval("alert a"); //Custom Error throw new Error("An error occured."); } catch(error) { if(error instanceof SyntaxError) { alert("Syntax Error"); } else if(error instanceof EvalError) { alert("Eval Error"); } else if(error instanceof RangeError) { alert("Range Error"); } else if(error instanceof ReferenceError) { alert("Reference Error"); } else if(error instanceof TypeError) { alert("Type Error"); } else if(error instanceof Error) { alert("Custon Error"); } alert(error.message); } </script> 注:浏览器不会抛出Error类型的exception异常,所以如果捕获到Error类型的异常,可以确定这个异常是用户代码抛出的,不是浏览器抛出的。javascript的assert() 代码如下:function assert(bCondition, sErrorMsg) {    if (!bCondition) {       alert(sErrorMsg);       throw new Error(sErrorMsg);    } }

这是主进程中于javascript脚本出现一个错误。主进程出现一个javascript错误。你的电脑上的java插件出错或者没有安装,下载安装最新的java程序,并且在浏览器的管理加载项中,启用java插件试试

相关标签:java

下一篇:teachingfeeling1.0.5有没有隐藏结局,如果有有什么要求才能达成?

上一篇:英语题,如图,求高人解答

热门标签:
英语 谜语 作文 数学 公式 语文 物理 化学 工艺 java c语言 实验 方程 金属 分子 数据库 硫酸 酒精 运算 石油 vc 世界大战 php 化合物 mysql
最新更新:
电学的一个小问题 为什么打点计时器只能粗略瞬时速度 lookdownupon用法 中专都考不上大学有必要复读一年吗? 如图,已知∠B=∠DEF,AB=DE,请添加一个条件使△ABC≌△DEF,则需添加的条件是__________. 求曲线y=2x^2和直线y=2的所围图形的面积 夜上受降城闻笛是哪句 这个怎么填数字? 小明家下五层楼是5楼,那么小明家上五层楼是几层楼? 填空题,这个题目是怎么算的呢…… 22335577()143中括号里填什么数字。 懂得人帮我看一下这个英文是啥意思??? 最小的物质单位是什么 怎么估算根号52000000 about的重读字母是哪里