在HTML文件中调试javascript [英] javascript debugging in HTML file

查看:150
本文介绍了在HTML文件中调试javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在javascript函数的HTML页面中放置断点,以便在行执行时查看变量的值。最简单的方法是什么?



谢谢

解决方案

使用关键字调试器; 来尝试调用硬断点。



只要您的浏览器启用了 Javascript调试,那么调试器; 语句将告诉它执行此操作你将会逐步调试。



Firefox的 Firebug 扩展程序是迄今为止最简单的扩展程序。 Explorer的新内置开发人员工具选项也很不错。 Firebug我必须说更简单,更精致,但我经常必须在一堆不同的浏览器中进行验证,在某些情况下只需要调试Internet Explorer就像调试客户端Javascript和自定义ActiveX控件的交互一样。



debugger; 语句似乎总是成为跨越平台和浏览器快速进入调试器的金钥匙,而不会跳过一堆燃烧的箍。 / p>

所以你可能会有一些Javacscript块,如下所示,浏览器将调用 debugger; 上的逐行调试器就像它是一个断点......



var a = 5;



var b = 6;



调试器;



a = b;


How can I put break points in an HTML page in javascript functions to see values of variables as lines get executed. What is the easiest way of doing so?

thanks

解决方案

Use the keyword "debugger;" to attempt invoking a hard breakpoint.

As long as your browser has Javascript Debugging enabled, then the debugger; statement will tell it to do it's thang and you'll be in a step-by-step debugger.

The Firebug extension for Firefox is by far the easiest, but Internet Explorer's new built-in "Developer Tools" option is quite nice too. Firebug I must say is easier and more polished, but I often must validate in a pile of different browsers and in some cases only Internet Explorer like when debugging the interaction of client-side Javascript and a custom ActiveX control.

The "debugger;" statement always seems to be the golden key to quickly get in to a debugger across platforms and browsers without jumping through a bunch of burning hoops.

So you might have some block of Javacscript like the following, and the browser would invoke the line-by-line debugger on "debugger;" like it was a breakpoint...

var a = 5;

var b = 6;

debugger;

a = b;

这篇关于在HTML文件中调试javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆