Detect errors on web page with Firebug

心不动则不痛 提交于 2019-12-13 15:13:18

问题


What is the best way to check our web applications for errors such as "duplicate attribute"?

My development team tends to use Firefox and Firebug for web development. We've noticed some errors creeping into the codebase, usually duplicate attributes such as:

<div id="MyDiv" class="hide" class="interestingDiv">

We see no errors in Firebug's console nor can see anyway to get Firebug to report that there are errors.

We have noticed that Firefox itself IS aware of these errors. By clicking on "View Page Source", Firefox renders the second class in red and has a tooltip of "Duplicate Attribute". However we have to hunt through the code ourselves looking for any errors highlighted in red.

Surely there is a better way than manually looking at the code? What tools should we be using?

Thanks,

Phil


回答1:


Firefox automatically corrects HTML errors like duplicate attributes, i.e. it just ignores the second attribute. It doesn't expose this as error to its Browser Console.

Firebug just displays the error messages Firefox exposes via its APIs, it doesn't anaylize the HTML/CSS/JavaScript by itself. So as Firefox doesn't produce an error message for incorrect HTML, Firebug's Console panel doesn't display anything related to that.

Though Firefox offers another way to display HTML errors via is its source view. To get there just right-click into the page and choose View Page Source from the context menu. This view highlights duplicate attributes in red:

Other options you have are:

  1. Use an HTML validator tool like the Html Validator add-on for Firefox or http://validator.w3.org/.
  2. You may want to follow the Firefox bug 878364 asking for exposing HTML errors.



回答2:


The W3 html validator will look through your html and check for these kinds of errors:

http://validator.w3.org/

EDIT: It looks like there's a Firefox add-on that validates HTML. I've never used it before but you might want to look into it:

https://addons.mozilla.org/en-US/firefox/addon/html-validator/



来源:https://stackoverflow.com/questions/26425716/detect-errors-on-web-page-with-firebug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!