忽略页面中的 javascript 语法错误并继续执行脚本 [英] Ignore javascript syntax errors in a page and continue executing the script

查看:49
本文介绍了忽略页面中的 javascript 语法错误并继续执行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 WordPress 开发插件.它在用户端(主题)使用一些 jquery 作为 jquery 插件.问题是,当其他作者制作的其他插件出现 javascript 错误时,我的插件的 javascript 无法执行.

I develop plugins for WordPress. It uses some jquery in the user side (themes) as a jquery plugin. The problem is, when there is an javascript error with other plugins made by other autors, my plugin's javascript fails to execute.

最糟糕的是人们认为我的插件存在严重错误,即使它在错误处理条件语句中 100% 正常工作.但这实际上是由于其他一些 WP 插件/主题作者的其他一些 javascript 语法错误造成的.

And the worst thing is people consider that there is a serious fault with my plugin even though it works 100% fine with error handling conditional statements. But it is actually due to some other javascript syntax errors of some other WP plugin/theme authors.

有没有办法继续执行我的插件 JS 而忽略其他 JS 错误.或者我可以有处理这个问题的建议吗??

Is there a way to continue execute my plugin JS ignoring other JS errors. Or can i have suggestions to handle this problem ??

推荐答案

尝试:

window.onerror = function(){
   return true;
}

也就是说,如果您可以在执行错误脚本之前包含此内容.

That is if you can include this before the bugged script has been executed.

这篇关于忽略页面中的 javascript 语法错误并继续执行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆