javascript Internet Explorer 脚本错误、来自网页的消息、权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3495364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Internet Explorer Script Error, Message from Webpage, Permission denied
提问by Brandon Boone
I'm working with an embedded (Active X?) instance of IE within a VB6 application.
我正在 VB6 应用程序中使用嵌入式(Active X?)IE 实例。
The browser displays demographic information based off the selected person (displayed as a list).
浏览器显示基于所选人员的人口统计信息(显示为列表)。
Everything works great until I try to quickly select different people from the list (clicking randomly over different people as fast as I can). After a few clicks, get two errors.
一切都很好,直到我尝试从列表中快速选择不同的人(尽可能快地随机点击不同的人)。单击几下后,出现两个错误。
The first is an "Internet Explorer Script Error"
第一个是“ Internet Explorer 脚本错误”
It says:
它说:
An Error has occurred in the script on this page
Line:
Char:
Error:
Code:
URL:
Do you want to continue running scripts on this page? yes|No
此页面上的脚本中发生错误
行:
字符:
错误:
代码:
URL:是否要继续在此页面上运行脚本?是|否
(Line, Char, Error, Code, URL are all blank).
(行、字符、错误、代码、URL 均为空白)。
The second error pops up directly over the first.
第二个错误直接在第一个错误上弹出。
It says:
它说:
"Message from webpage
"来自网页的消息
An error has occurred in this dialog
Error:53 Permission denied"
此对话框中出现
错误错误:53 权限被拒绝“
The page makes multiple ajax calls and also contains several iFrames (I'm thinking these are the cause).
该页面进行多个 ajax 调用,还包含多个 iFrame(我认为这些是原因)。
Any advice on how to debug / resolve / avoid the problem would be most appreciated.
任何关于如何调试/解决/避免问题的建议将不胜感激。
Thanks!
谢谢!
EDIT
编辑
Here is an image of the error
这是错误的图像
EDIT
编辑
I get a JScript anonymous function, No source available when I do happen to catch the error.
我得到一个 JScript 匿名函数,当我碰巧捕捉到错误时没有可用的源。


EDIT
编辑
I've successfully caught some of the errors. It seems that they are stemming primarily from MicrosoftAjax.js
我已经成功地发现了一些错误。似乎它们主要源自 MicrosoftAjax.js
- Occurs Consistently: MicrosoftAjax.js - Sys._Application.callBaseMethod(this,"initialize"); Object Expected
- Occurred Once: jquery-1.4.2.min.js - b.InsertBefore(d,b.firstChild) Object Expected
- Occurred Once: Out of Memory Exception.
- 持续发生:MicrosoftAjax.js - Sys._Application.callBaseMethod(this,"initialize"); 预期对象
- 发生一次:jquery-1.4.2.min.js - b.InsertBefore(d,b.firstChild) Object Expected
- 发生一次:内存不足异常。
My host application is not using MicrosoftAjax.js at all, but the child iFrame applications are all asp.Net applications.
我的主机应用程序根本没有使用 MicrosoftAjax.js,但子 iFrame 应用程序都是 asp.Net 应用程序。
回答by Brandon Boone
After a lot of testing and trying to figure out if I really needed to edit MicrosoftAjax.js to fix the problem, I finally found a solution that seems to have resolved the issue.
经过大量测试并试图弄清楚我是否真的需要编辑 MicrosoftAjax.js 来解决问题后,我终于找到了一个似乎已经解决了问题的解决方案。
I added,
我补充说,
<script type="text/javascript">
window.onerror = function (e) { return true; }
</script>
to the header of ever application that I was pulling in via the iFrames, as well as to the parent page. It's been about two days since I made these changes and so far so good (though I'll need a few more days of testing to confirm that it's working 100%).
到我通过 iFrame 引入的任何应用程序的标题,以及父页面。自从我进行这些更改以来已经过去了大约两天,到目前为止一切顺利(尽管我还需要几天的测试才能确认它 100% 正常工作)。
I had tried this before without success, but that was due to the position of the Script. I had other scripts (like jQuery and MicrosoftAjax) that were positioned before it. Those scripts threw errors before my window.onerror script was even evaluated.
我之前尝试过这个没有成功,但这是由于脚本的位置。我有其他脚本(如 jQuery 和 MicrosoftAjax)位于它之前。这些脚本在我的 window.onerror 脚本被评估之前就抛出了错误。
Another interesting thing is that the iFrame errors seem to bubble up regardless of the error handling on the parent page. So I went into our Code repository and made the necessary changes to each of the applications I was pulling in.
另一个有趣的事情是,无论父页面上的错误处理如何,iFrame 错误似乎都会冒泡。因此,我进入了我们的代码存储库,并对我引入的每个应用程序进行了必要的更改。
Lastly, I want to say thank you to @Jacob for his initial help in troubleshooting this issue.
最后,我要感谢 @Jacob 在解决此问题时提供的初步帮助。
EDIT
编辑
Just wanted to add that I would have preferred to fix the error over burying it, but in the interest of time, this is the solution I've gone with for now.
只是想补充一点,我宁愿修复错误而不是埋葬它,但为了节省时间,这是我现在采用的解决方案。
回答by Jacob
If you want to just suppress Javascript errors, try setting the Silentproperty of the WebBrowserto True.
如果您只想抑制 Javascript 错误,请尝试将 的Silent属性设置WebBrowser为True。
回答by Jacob
I've found that most of the IE "Permission denied" errors have to do with sharing Javascript objects between windows/frames. Since you produce it with rapid random clicking, I'm guessing this has to do with iframes/windows going away while their content is still being accessed.
我发现大多数 IE“权限被拒绝”错误与在 Windows/框架之间共享 Javascript 对象有关。由于您通过快速随机点击生成它,我猜这与 iframes/windows 在其内容仍在访问时消失有关。
One strategy you could use to avoid these problems is to never share any objects between frames. Wherever an object is created, that frame should be responsible for all operations and access to its members. Outside access should be controlled completely through calls to "interface" Javascript functions.
您可以用来避免这些问题的一种策略是永远不要在帧之间共享任何对象。无论在何处创建对象,该框架都应负责所有操作和对其成员的访问。应通过调用“接口”Javascript 函数来完全控制外部访问。
回答by tomsv
Try
尝试
WebBrowser1.ScriptErrorsSuppressed = true;

