Javascript “confirm” in IE6 and IE7
<p>Why doesn't this code work in IE6 or IE7?</p>

<pre><code>$('a').click(
    function()
    {
        var urlIsExternal = true;

        var urlMedicareDir = '/medicare/';
        var urlMedicareHost = 'health.healthcare.com';
        var urlMedicare = 'https://' + urlMedicareHost + urlMedicareDir;

        var urlAppsHost = 'apps.healthcare.com';

        var urlCurrent = String( window.location );
        var urlCurrentPrefix = urlCurrent.substring( 0, urlMedicare.length );
        var urlCurrentURL = $.url( urlCurrent );

        var urlClicked = $(this).attr('href');
        var urlClickedURL = $.url( $(this).attr('href') );

        var urlHost = urlClickedURL.attr('host');

        if( !urlHost.length )
        {
            urlHost = urlCurrentURL.attr('host');
        }

        var urlConfirmMessage = 'You are now leaving the Medicare website.';

        if( urlCurrentPrefix == urlMedicare )
        {
            if( urlClicked.substring( 0, 1 ) == '/' ) // starts with slash
            {
                if( urlClicked.substring( 0, urlMedicareDir.length ) == urlMedicareDir )
                {
                    urlIsExternal = false;
                }
            }

            if( urlClicked.substring( 0, urlMedicare.length ) == urlMedicare )
            {
                urlIsExternal = false;
            }

            if (
                urlClicked.substring( 0, 1 ) != '/' &amp;&amp;
                urlClicked.substring( 0, 4 ) != 'http' &amp;&amp;
                urlClicked.substring( 0, 4 ) != 'file'
            )
            {
                urlIsExternal = false;
            }

            if( urlAppsHost == urlHost )
            {
                urlIsExternal = false;
            }

            if( urlClicked.substring(urlClicked.length-4) == '.pdf' )
            {
                urlIsExternal = false;
            }
        }
        else
        {
            urlIsExternal = false;
        }

        if( urlIsExternal )
        {
            if( confirm( urlConfirmMessage ) )
            {
                window.open( urlClicked );
                return false;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return true;
        }
    }
);
</code></pre>

<p>For some reason when the links are clicked in IE6 or IE7, they do not direct the user to the link and it does not prompt a confirm dialog. It should prompt a confirm dialog, but for some reason, it is not.</p>
