Posts Tagged ‘ie7’

Debugging javascript in ie7

May 5th, 2011

This is a dispersed article about caveats I found when forced to debug javascript in IE7.

Out of date web browser.  Out of date script engine.  Limping solution.

To fire up the debugger, enter

debugger;

as javasctipt on a row exceuting before where you want to start debugging.  One could probably divide by zero or something that makes IE throw up a dialogue asking if you want to debug or not.  and then answer yes…

There doesn’t seem to be any good official debugger for IE7, unless you have Visual studio installed.  Search the web and there is a NT4-compatible Microsoft Script Debugger; it is not very good.  There is one or more solutions but this is the only I have tried.

If you get a dialogue/error message

Request format is invalid: application/json; charset=utf-8

when working with jquery and ajax on an iis / dotnet solution, it might be due to missing lines in web.config.  The code below is for Dotnet3.5.  I don’t know what it looks like in 2.0 or 4.0.

<system.web>

<httpHandlers>
<remove path=”*.asmx” verb=”*” />
<add path=”*.asmx” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ validate=”false” verb=”*” />
<add path=”*_AppService.axd” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ validate=”false” verb=”*” />
<add path=”ScriptResource.axd” type=”System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ validate=”false” verb=”GET,HEAD” />
</httpHandlers>
</system.web>

 

Ajax JSON.stringify IE7 problem

May 4th, 2011

Just a tip up front.  IE7 runs an older script engine than IE8 and has no full support for Json.

So your code that calls JSON.stringify does not work.

The remedy is to include json2.js from https://github.com/douglascrockford/JSON-js/blob/master/json2.js.  It does not interfere with IE8+.  Just download the file (the “raw” button – saveas) to your script lib and include as so:

<script src="Script/json2.js"; type="text/javascript"></script><!-- Needed for IE7. -->

Running IE9 in compatibility mode does not make this error appear – it seems like IE9-in-IE7-mode is running a newer script engine.

That impediment avoided you are free to continue adding value to your site.