{"id":119,"date":"2007-02-08T09:08:26","date_gmt":"2007-02-08T08:08:26","guid":{"rendered":"http:\/\/www.itwriting.com\/blog\/?p=119"},"modified":"2007-02-08T09:08:26","modified_gmt":"2007-02-08T08:08:26","slug":"ie7-script-madness","status":"publish","type":"post","link":"https:\/\/www.itwriting.com\/blog\/119-ie7-script-madness.html","title":{"rendered":"IE7 script madness"},"content":{"rendered":"<p>Ever seen this guy?<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"435\" src=\"http:\/\/www.itwriting.com\/images\/stopscript.gif\" alt=\"Stop running this script dialog in IE7\" height=\"217\" style=\"width: 435px; height: 217px\" title=\"Stop running this script dialog in IE7\" \/><\/p>\n<p>I&#8217;m writing a piece on Javascript. In the new world of\u00a0AJAX, web applications may run large amounts of client-side code in the browser. I&#8217;m having a look at performance issues, so I wrote some code that does some processing in a tight loop and tested it in IE7, FireFox 2.0 and Flash 9.<\/p>\n<p>Getting timings was difficult, because IE7 pops up this &#8220;Stop running this script&#8221;\u00a0dialog\u00a0when my code is running. Nor will it let go. You click &#8220;No&#8221;, and 1 second later the dialog pops up again. And again. And again.<\/p>\n<p>I&#8217;ve trawled through the IE7 options looking for a way to switch this thing off, but cannot find one. I&#8217;m hoping I&#8217;ve missed it, or that there is a secret registry key I can change, because it is really annoying.<\/p>\n<p>I don&#8217;t understand why there is no option for\u00a0&#8220;don&#8217;t ask me again&#8221;, or &#8220;allow long-running scripts at this site&#8221;. After all, this scenario is going to get increasingly common.\u00a0Neither FireFox nor Flash suffers from this problem.<\/p>\n<p>I appreciate that IE7 is trying to be helpful here. There is though a fine line between helpful and annoying. Without any obvious way to prevent it, this falls in the latter category.<\/p>\n<p>That said, I did find a way to get my timings, because of my experience with the <a target=\"_blank\" href=\"http:\/\/www.itwriting.com\/htmleditor\/index.html\">htmleditor<\/a>. \u00a0If you host Mshtml in an application, you can implement the COM interface IDocHostShowUI. This has a ShowMessage function which IE calls when it wants to show a dialog. This enables you to catch the over-helpful &#8220;stop this script&#8221; message and not show it.<\/p>\n<p>Unfortunately this solution isn&#8217;t something users can easily apply. It requires creating your own customized version of IE. There must be some easier way and I look forward to learning what it is.<\/p>\n<p>One last comment: why does Microsoft still come up with poorly thought-out UI elements like this? It is easy to think of better ways than a brutal modal dialog. How about a &#8220;stop script&#8221; toolbar button that appears only when scripts are taking too long or grabbing too much CPU?<\/p>\n<h3>Update<\/h3>\n<p>FireFox does exactly the same thing, also with a modal dialog, &#8220;A script on this page may be busy&#8221; &#8230;<\/p>\n<p>Still, two benefits to FireFox. First, the timeout is set to a more reasonable 10 seconds. Second, you can easily amend it. Navigate to about:config. Find the entry dom.max_script_run_time. Change it from 10 to whatever you like.\u00a0<\/p>\n<h3>Further update<\/h3>\n<p>A comment has pointed me to this <a href=\"http:\/\/support.microsoft.com\/default.aspx?scid=kb;en-us;175500\">knowledgebase article<\/a>.<\/p>\n<p>Here&#8217;s the fix:<\/p>\n<ol>\n<li>\n<p>Using a Registry Editor such as Regedt32.exe, open this key:<br \/>\nHKEY_CURRENT_USER\\Software\\Microsoft\\InternetExplorer\\Styles<\/p>\n<p>Note If the Styles key is not present, create a new key that is called Styles.<\/p>\n<\/li>\n<li>\n<p>Create a new DWORD value called &#8220;MaxScriptStatements&#8221; under this key and set the value to the desired number of script statements.<\/p>\n<p>By default the key doesn&#8217;t exist. If the key has not been added, Internet Explorer 4 defaults to 5,000,000 statements executed as the trigger for the time-out dialog box.<\/p>\n<\/li>\n<\/ol>\n<p>Technorati tags: <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/ie7\">ie7<\/a>, <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/software%20development\">software development<\/a>, <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/javascript\">javascript<\/a>, <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/firefox\">firefox<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>IE7 pops up this &#8220;Stop running this script&#8221; dialog when my code is running. Nor will it let go. You click &#8220;No&#8221;, and 1 second later the dialog pops up again. And again. And again.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,55,80,96,97],"tags":[],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-internet","category-microsoft","category-software-development","category-web-authoring","category-windows"],"_links":{"self":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":0,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}