philipwalton/html-inspector

Support for IE (8+)?

kimptoc opened this issue · 7 comments

Hi,

Thanks for this - very handy.

Any plans for support for IE? (or tips to make it work with IE.. should I be using modernizr?)

I currently get this error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.2; .NET4.0C; .NET4.0E)
Timestamp: Mon, 8 Jul 2013 06:45:57 UTC


Message: Object doesn't support this property or method
Line: 1208
Char: 3
Code: 0
URI: http://localhost:8080/js/html-inspector.js

Line 1208 is this:

  var elements = Object.keys(elementData).sort()

Thanks, Chris

Thanks for the reminder. I've been meaning to put something in the README indicating browser support.

Since HTML Inspector is primarily a dev/test tool and not a production tool, I don't intend to support old IE. As such, I can use a lot of ES5 methods (like Object.keys as you pointed out) that old browsers don't support.

If you really want/need it to run in old IE you could always add an ES5 Shim and then override the onComplete handler to do something other than logging to the console (since old IE doesn't support console.log).

@philipwalton To clarify, IE7+ actually supports console.log, just only when the developer tools open.

Cool - thanks - must put my thinking cap on and find a way to only include the inspector in dev/chrome - maybe I will make my index.html an erb file and only include it as appropriate.

Rumour has it our corp browser will be IE10 by year end... although there has been rumours of an option to use Chrome as well circulating....

Yeah, I had that same problem with installing it on our work app. The solution I used (which is crappy) is to only include HTML Inspector if the domain is localhost. Since we use macs and do all our IE testing with VMWare, that solution works for us because our IE testing domain is never localhost.

You could also try using IE conditional comments, which can be used to negate a condition (e.g., only include this code if the browser isn't IE).

I'll also spend some time thinking about a better solution as well, and keep this issue open until it's resolved.

One solution is to use the CLI feature once it's released (i.e. HTML Inspector does its job through PhantomJS).

Anyway, can anybody report whether it actually works in oldIE using ES5 shim? And I guess it's good practice to feature test for window.console before using it in any case.

I've tried using HTML Inspector with IE7-10 and, even with the es5-shim, IE10 is the only one that reports the correct errors. IE9 doesn't error but it doesn't report the same HTML Inspector warnings that all other browsers correctly report. I might look in to this further, but I suspect the primary reason is that IE7-9 don't fully support the CSSOM, which is giving the CSS-related rules problems.

Because HTML Inspector is a development tool, I don't think there's any compelling reason to support non-standard browsers; however, there should be an easy way add HTML Inspector to your dev setup and not have it completely break in old IE.

At this point I think the best way is to use IE conditional comments, which I've currently switched my setup to use with no issues so far:

<!--[if gt IE 9]><!-->
  <script src="path/to/html-inspector.js"></script>
<!--<![endif]-->

Unless anyone strongly objects or has a better idea, I'll add this info and a more general browser support section to the README.

Works for me - thanks :)