calendarNovember 20, 2007 in HttpWatch , Internet Explorer , Javascript

Some customers contacted us recently to ask why they were seeing http://:/ recorded in HttpWatch. This URL produces an ‘Error 0x57’ in IE 6 and ERROR_INTERNET_INVALID_URL on IE 7.

The sites causing these errors had one thing in common. They were either using the jQuery or YUI javascript libraries. It was not immediately obvious where this URL was being generated because there was nothing in the DOM with that URL when we checked with the IE Developer Toolbar.

We set up a simple test page using the commented version of the jQuery library. If you access this page using HttpWatch you will see http://:/ being recorded as the page is loaded:

jQuery Demo

Then we searched for //:  guessing that IE was adding the http: prefix and the trailing forward slash.  HttpWatch highlighted the following piece of code in jquery.js. It is used on IE to generate an event that is equivalent to Firefox’s DOMContentLoaded:

IE Defer Script Hack

The jQuery library avoids using the standard window.onload event because it doesn’t fire until the page and all its images have been completely downloaded. This can lead to significant delays in providing javascript based functionality on a page. The advantage of using the DOMContentLoaded event is that it fires as soon as the page’s DOM elements can be safely accessed from javascript.

The workaround for the lack of the DOMContentLoaded event in IE uses a temporary <script> block to generate an event. However, the onreadystatechanged event of the <script> block will only fire at the correct time if the defer attribute is used and the script block has a src attribute. The value used in the src attribute causes the invalid URL that was recorded in HttpWatch.

The temporary <script> block is deleted when the event is triggered leaving no trace in the page’s DOM.

A similar workaround for IE is used in the YUI library:

YUI Defer Script Hack

You can see the resulting http://:/ if you go to the YUI Event Example:

YUI Event Example

The //: value in the src attribute is a compromise solution. If it contained a real URL it would trigger an extra network round-trip. The invalid URL used does cause the error seen in HttpWatch but the effect on performance if minimal. In the YUI Event Example shown above it only adds 3 milliseconds to the download time of the whole page.

4 thoughts on “ERROR_INTERNET_INVALID_URL & HttpWatch

  1. Detlev Beutner says:

    At least on IE7 the replacement of “//:” by “about:blank” should do the trick (as far as I remember, on IE6 “about:blank” led to security warnings if called in an HTTP context). So – such JS lib providers maybe should change their implementation – the “about:blank” not only leads to no error message in httpWatch, but also generates to internal request at all, saving 1-3 millisecs.

  2. esnouf says:

    You have the same behavior using another library, named DOJO. If in HTTPwatch you see that such GET takes 0 seconds that is fine. If it takes more (I have seen 6 seconds) then it has a serious impact on the application performance. You should then replace the code and use a good URL to speedup the process. You can either change that on the application itself, or if you publish this application via a reverse proxy or a VPN/SSL, in the box itself if it has a “rewriting on the fly” technology.

  3. Eric Yan says:

    I have the same library as esnouf.
    The first time i load the page,the http://:/ takes about 30 seconds,which it’s serious impact the performance.

  4. dingjsh says:

    dear Eric Yan
    I have the same problem with you,I don’t have a clue to solve this problem.Do you have any suggestions.I really appreciate it. Please forgive me for my poor english

Got Something to Say?

Your email address will not be published.

Ready to get started? TRY FOR FREE Buy Now