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

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

问题描述

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



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



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



解决方案

试试:

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

也就是说,如果您可以在执行错误脚本之前包含它。 / p>

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.

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.

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

解决方案

Try :

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

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

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

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