简体   繁体   English

IE8调试ASCX组件停止时未在javascript代码中显示正确的位置

[英]IE8 debugging ASCX component doesn't show correct location in javascript code when it stops

I have an ASCX component that has a lot of javascript declared in a script tag in the ascx itself. 我有一个ASCX组件,它在ascx本身的script标记中声明了很多javascript。 I can set breakpoints, and the debugger stops as it should, but the text that is highlighted in the debugger as the "current line" is nowhere near the actual javascript (it is much higher in the rendered file than it should be). 我可以设置断点,并且调试器应按其应有的方式停止,但是在调试器中以“当前行”突出显示的文本与实际的javascript位置相去甚远(在呈现的文件中比应有的文本高得多)。 I can "wing it" for one or two lines with the real code side-by-side with the "false" line of execution, but I lose all the hover abilities and everything else that makes javascript debugging useful. 我可以用“ false”执行行将实际代码与“代码”并排执行一两行,但是我失去了所有的悬停功能以及所有其他使javascript调试有用的功能。

I have tried putting the script at the top of my ascx file, but to no avail. 我尝试将脚本放在ascx文件的顶部,但无济于事。 I've tried not setting a breakpoint until the entire page is rendered, so that I have to scroll all the way to where the actual lines of code are, and the debugger still stops somewhere way above it. 我尝试在呈现整个页面之前不设置断点,以便必须一直滚动到实际代码行所在的位置,并且调试器仍在其上方的某个位置停止。

Has anyone else seen this or no how to get around it? 有没有其他人看到这个或没有解决方法?

Please don't answer with suggestions about using a different browser. 请不要回答有关使用其他浏览器的建议。 This site doesn't work except in IE7 and IE8. 除IE7和IE8外,该站点无法正常工作。

Thanks! 谢谢!

Finally!!! 最后!!!

I have been looking for a solution to this question for MONTHS! 我一直在为MONTHS寻找这个问题的解决方案!

This worked for me: 这为我工作:

<script type="text/javascript" language="javascript">
  debugger
    function ThrowError() {
        $(function () {
            $.openDOMWindow({
                loader: 0,
                width: 500,
                height: 250,
                windowSourceID: '#ErrorAlert'
            });
            return false;
        });
    }
    function CloseError() {
        $(function () {
            $.closeDOMWindow({});
            return false;
        });
    }

    if ("False" == "True") ThrowError();
</script>

I don't know if I'm using it correctly, but it seems to give me what I need. 我不知道我是否使用正确,但这似乎可以满足我的需求。

Thank you!! 谢谢!!

Move the script to an external JS file. 将脚本移至外部JS文件。
(This is good practice anyway) (无论如何,这是个好习惯)

I'm dealing with the same issue as you're. 我正在处理与您相同的问题。 I can't move the js code to an external JS (because the guy who wrote the code is using the variables of .cs with <%= var %>. The simplest solution that i've found is write debugger; wherever you want the browser to start debugging the script. 我无法将js代码移至外部JS(因为编写代码的人正在将.cs变量与<%= var%>一起使用。我发现的最简单的解决方案是编写调试器;无论您在哪里浏览器开始调试脚本。

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

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