停止 HTA 中的错误报告(无需管理员权限)
我使用带有框架的 HTA,左侧框架控制主框架并在其中显示页面(如导航面板),例如:您按左侧的“google”链接,它会在主窗口中打开它。 (这不是 HTA 的主要目的,但我只是简化解释)
现在的问题是当我尝试打开带有错误报告的网页时 - HTA 不断通知我有关页面的错误,有时甚至是页面的错误甚至无法正常运作。 (错误报告与我创建的页面无关!) 相同的页面在 IE 中完美运行。
正如标题中所提到的,我或任何 HTA 的用户在系统中没有管理员权限,这一点很重要。
我用谷歌搜索了很长时间,但从未找到解决方案,我将非常感谢任何有用的提示或问题的解决方案。
谢谢, 罗特姆
I'm using HTA with frames, the left frame controls the main frame and show pages in it (like a navigation panel), for example: You press the 'google' link on the left and it opens it on the main window. (This isn't the primary HTA's purpose, but I just simplify it to explain)
Now the problem is when I'm trying to open a web page with bug reports - The HTA is keep informing me about the page's bugs and sometimes the page even doesn't function properly. (The bug reports are not about pages that I created!)
The same pages works perfectly in IE.
It is important to mention as in the title, that I or any of the HTA's users doesn't have admin privileges in the system.
I googled it for a long time, but never found a solution, I will really appreciate any helpful tip or solution to the problem.
Thanks,
Rotem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有几种选择可以解决这个问题。最好的选择是在 Internet Explorer 中禁用“显示有关每个脚本错误的通知”设置。由于您正在运行 HTA,因此您可以通过编程方式修改 HKEY_CURRENT_USER 注册表设置(或者只需手动执行一次。)
第二种方法肯定更像是一种 hack,但这是我之前在 HTA 中创建选项卡式浏览器时自己解决问题的方法IE 具有标签式浏览功能。您不需要导航到 iframe 中的 URL,而是希望通过 AJAX 请求内容,并在前面添加一个脚本块,将 window.onerror 设置为您选择的函数。然后将全部内容注入到 iframe 中。这种方法将吞掉所有错误,并让您可以选择根据需要报告它们。
除了注入 onerror 脚本之外,您还需要对锚点进行一些预解析,以便后续点击通过 ajax 注入处理程序进行路由。事实证明这非常复杂,因为您基本上开始编写自己的浏览器。我仍然拥有该项目的源代码,因此我会将其发布到 bitbucket 存储库并让您探索我的方法。
否则,最后一个选择是向每个站点的管理员发送电子邮件并告诉他们修复他们的错误!!!!但我怀疑这个选项是否适合您:D
编辑:
加载旧项目后,我发现该解决方案的可行性不如以前。自 IE8 以来,x-frame-options 标头指令现在甚至可以阻止 google.com 加载到 iframe 中。由于某种原因,window.onerror 陷阱没有捕获 iframe 中的错误(实际上可能是嵌套 iframe 问题,但我没有可行的解决方案。)
但我仍然可以选择检查“不再显示此消息”错误对话框的选项。这使得错误对话框停止为我报告问题,并且不需要管理员权限。
you have a couple options to get around this problem. The best option is to just disable the setting "display a notification about every script error" in Internet Explorer. Since you are running an HTA you could modify the HKEY_CURRENT_USER registry setting programmatically (or just manually do it once.)
The second approach is definitely more of a hack but it's how I solved the problem myself when I created a tabbed browser in an HTA before IE had tabbed browsing. Instead of navigating to the URL in the iframe, you'll instead want to AJAX request the content, prepend a script block that sets window.onerror to a function of your chosing. Then inject the entire contents into the iframe. This approach will swallow any errors and give you the option of reporting them as you wish.
In addition to injecting the onerror script, you will also need to do some pre-parsing on anchors so that subsequent clicks are routed through the ajax injection handler. This proved to be pretty complex because you essentially begin writing your own browser. I still have the source code to the project so I'll publish it to a bitbucket repo and let you explore my approach.
Otherwise the last option is to send an email to the administrators of each site and tell them to fix their friggin bugs!!!! but I doubt that option will pan out for you :D
EDIT:
After loading up the old project I have discovered that the solution is less viable than it used to be. The x-frame-options header directive now prevents google.com from even loading in an iframe since IE8. And for some reason the window.onerror trap isn't catching the errors in the iframe (could be a nested iframe issue actually, but I don't have a viable solution for that.)
But I still had the option of checking the "Do not show this message again" option of the error dialog. That makes the error dialog stop reporting issues for me and it didn't require admin privileges.