简体   繁体   English

在IE中调试模式对话框(showModalDialog)

[英]Debug a modal dialog (showModalDialog) in IE

I want to debug (examine DOM, use the interactive JS console, etc) part of a web application that is inside a modal dialog that was created by showModalDialog() . 我想调试(检查DOM,使用交互式JS控制台等)Web应用程序的一部分,该应用程序位于由showModalDialog()创建的模式对话框中。

I can't find a way to use the standard IE-8 developer tools for this; 我无法找到使用标准IE-8开发人员工具的方法; The dialog doesn't have a toolbar and the usual shortcut (F12) doesn't work. 该对话框没有工具栏,通常的快捷方式(F12)不起作用。


Another SO question (I unfortunately have lost the link to) suggested that the only solution is to (perhaps temporarily) replace showModalDialog() with an old-fashioned window.open() . 另一个SO问题(我遗憾地失去了链接)表明唯一的解决方案是(可能暂时)用老式的window.open()替换showModalDialog() window.open() If this is the case, is there a straightfoward way to do it? 如果是这种情况,是否有直接的方式来做到这一点?

Caveats: 注意事项:

  • The app cares about passing dialogArguments and the return value of showModalDialog 该应用程序关心传递dialogArguments和showModalDialog的返回值
  • I can't use other browsers, FF+Firebug, etc. 我不能使用其他浏览器,FF + Firebug等。

F12 works to bring up the developer tools if you turn the address bar on. 如果打开地址栏,F12可以调出开发人员工具。

Go Tools / Internet options / Security / (pick the right zone for your site) / Custom Level Under "Miscellaneous" Under "Allow websites to open windows without address or status bars", choose "Disable". 转到工具/ Internet选项/安全/(为您的站点选择正确的区域)/自定义级别在“其他”下的“允许网站打开没有地址或状态栏的窗口”下,选择“禁用”。

Source: https://stackoverflow.com/a/10984858/79835 资料来源: https//stackoverflow.com/a/10984858/79835

i do it by creating an error in the js code, which then brings up the error window asking if you want to debug the script. 我通过在js代码中创建一个错误来执行此操作,然后调出错误窗口,询问您是否要调试脚本。

one way to do that would be to call a non-existent method somewhere in the code. 一种方法是在代码中的某处调用一个不存在的方法。

eg blabla(); 例如blabla();

You can now put the word debugger without quotes in your javascript. 你现在可以在你的javascript中放置没有引号的debugger

IE and Chrome should both break on it as if you had set a breakpoint on it. IE和Chrome都应该打破它,好像你已经设置了一个断点。 Make sure its on a line by itself. 确保它自己在一条线上。 Press F12 to open the browser debugger and then refresh your page or trigger the event to run your javascript and the debugger should automatically display the code with the breakpoint set. 按F12打开浏览器调试器,然后刷新页面或触发事件以运行您的javascript,调试器应自动显示设置断点的代码。

What I do when i'm debugging modal windows are two things. 我在调试模态窗口时所做的是两件事。

  • You can include in your js code the instruction debugger; 您可以在js代码中包含指令调试器; that will stop the js execution as if you had put a breakpoint. 这将停止js执行,就好像你放了一个断点。
  • You can also open the ie developer tools before opening the modal window and, once it's open, you can review the generated code in the script tab, adding breakpoints, pausing execution,... everything you need. 您也可以在打开模态窗口之前打开ie开发人员工具,一旦打开,您可以在脚本选项卡中查看生成的代码,添加断点,暂停执行,......您需要的一切。

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM