开发者

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

开发者 https://www.devze.com 2023-01-10 02:52 出处:网络
I have an ASCX component that has a lot of javascript declared in a script tag in the ascx itself.I can set breakpoints, and the debugger stops as it should, but the text that is highlighted in the de

I have an ASCX component that has a lot of javascript declared in a script tag in the ascx itself. 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). 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.

I have tried putting the script at the top of my ascx file, but to no avail. 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.

Thanks!


Finally!!!

I have been looking for a solution to this question for 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.
(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.

0

精彩评论

暂无评论...
验证码 换一张
取 消