Javascript 在 IE 中调试模态对话框 (showModalDialog)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4908729/
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
Debug a modal dialog (showModalDialog) in IE
提问by hugomg
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 控制台等)由showModalDialog()
.
I can't find a way to use the standard IE-8 developer tools for this;The dialog doesn't have a toolbar and the usual shortcut (F12) doesn't work.
我找不到为此使用标准 IE-8 开发人员工具的方法;该对话框没有工具栏,通常的快捷键 (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()
. If this is the case, is there a straightfoward way to do it?
另一个 SO 问题(不幸的是我失去了链接)建议唯一的解决方案是(也许暂时)用showModalDialog()
老式的window.open()
. 如果是这种情况,是否有直接的方法来做到这一点?
Caveats:
注意事项:
- The app cares about passing dialogArguments and the return value of showModalDialog
- I can't use other browsers, FF+Firebug, etc.
- 该应用程序关心传递 dialogArguments 和 showModalDialog 的返回值
- 不能用其他浏览器,FF+Firebug等。
回答by row1
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".
转到工具/互联网选项/安全/(为您的站点选择正确的区域)/自定义级别在“其他”下的“允许网站打开没有地址或状态栏的窗口”下,选择“禁用”。
回答by H77
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.
一种方法是在代码中的某处调用一个不存在的方法。
e.g. blabla();
例如 blabla();
回答by albervera
What I do when i'm debugging modal windows are two things.
我在调试模态窗口时所做的有两件事。
- You can include in your js code the instruction debugger; that will stop the js execution as if you had put a breakpoint.
- 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.
- 您可以在 js 代码中包含指令调试器;这将停止 js 执行,就像你放置了一个断点一样。
- 您还可以在打开模态窗口之前打开 ie 开发人员工具,一旦它打开,您就可以在脚本选项卡中查看生成的代码、添加断点、暂停执行……您需要的一切。
Hope it helps!
希望能帮助到你!
回答by Bill
You can now put the word debugger
without quotes in your javascript.
您现在可以debugger
在 javascript 中放置不带引号的单词。
IE and Chrome should both break on it as if you had set a breakpoint on it. 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.
IE 和 Chrome 都应该在它上面中断,就好像你在它上面设置了一个断点一样。确保它自己在一条线上。按 F12 打开浏览器调试器,然后刷新页面或触发事件以运行 javascript,调试器应自动显示设置断点的代码。