JavaScript Function Randomly Broke in IE9
<p>I'm having issue with my site where the main nav no longer works in IE9.  It worked before, but then all of a sudden, it stopped working.  Strangely, if I visit the site on IE9, they work, but then when I ctrl+f5 the page, then it break.</p>

<p>I'm assuming there is a problem in my custom.js file as that's the file with my main "Nav Bar" js coding.  I am not sure if it's coded entirely properly, but the site works perfectly in chrome, firefox, safari, so I don't really feel like the JS is messed up.</p>

<p>custom.js is right here: (focus on [4] Nav Bar I'm Assuming)</p>

<pre><code>/* --------------------------------------------------------------

INDEX:

[1] Search
[2] Popout Window
[3] Form Numbers
[4] Nav Bar
[5] Smooth Scroll
[6] Similar Pages Sidebar
[7] Estimate Form

-------------------------------------------------------------- */

/* --------------------------------------------------------------

[1*] Search

-------------------------------------------------------------- */

document.getElementById('headerSearch').onsubmit = function() {
    window.location = "javascript:poptastic('http://www.google.com/search?q=site:northtownsremodeling.com ' + document.getElementById('headerInput').value);"
      return false;}

/* --------------------------------------------------------------

[2*] Popout Window

-------------------------------------------------------------- */

var newwindow; function poptastic(url){
  newwindow=window.open(url,'name', 'height=800,width=1020,scrollbars=yes');
    if (window.focus) {newwindow.focus()}}

/* --------------------------------------------------------------

[3*] Form Numbers

-------------------------------------------------------------- */

jQuery(function($){
    $("#menu-primary-number").mask("(999) 999-9999");
    $("#menu-zip").mask("99999");
});

/* --------------------------------------------------------------

[4*] Set Selected Menu Items &amp; Hide

-------------------------------------------------------------- */
/*START FUNCTION*/
$(function() {

    $("#header-subnav ul").hide();
    $('.menu-option-set a[data-subid]').on('click', function(e) {
        e.preventDefault();
        var $s = $("#" + $(this).attr('data-subid'));                
        if($s.is(':hidden')) {
            $("#header-subnav").removeClass('hidden');
            $("#header-subnav ul").hide();
            $s.show();
        } else {
            $s.hide();
            $("#header-subnav").addClass('hidden');
        }
    });

    $('.menu-option-set a').click(function()
    {
        // if clicked item is selected then deselect it
        if ($(this).hasClass('selected'))
        {
            $(this).removeClass('selected');
        }

        // otherwise deselect all and select just this one
        else
        {
            $('.menu-option-set a').removeClass('selected');
            $(this).addClass('selected');
        }
    });
});

/* --------------------------------------------------------------

[5*] Smooth Scroll

-------------------------------------------------------------- */
$(function() {
    $('.navbar a, .scroll a, .smoothscroll a').bind('click',function(event){
        var $anchor = $(this);

        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 850,'easeInOutExpo');
        /*
        if you don't want to use the easing effects:
        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 1000);
        */
        event.preventDefault();
    });
});

/* --------------------------------------------------------------

[6*] Similar Pages Sidebar

-------------------------------------------------------------- */
$(function() {
  $("a.show-similar-pages").click(function(e) {
    $("#sidebar").removeClass('mobile-phone-hide');
    $("#show-similar-pages").addClass('hidden');
    $("#hide-similar-pages").removeClass('hidden');
    e.preventDefault();
  });
  $("a.hide-similar-pages").click(function(e) {
    $("#sidebar").addClass('mobile-phone-hide');
    $("#hide-similar-pages").addClass('hidden');
    $("#show-similar-pages").removeClass('hidden');
    e.preventDefault();
  });
});

/* --------------------------------------------------------------

[7*] Estimate Form

-------------------------------------------------------------- */
$(function() {
    // Setup any needed variables.
    var $form   = $('.estimate-menu-form'),
        $loader = '&lt;img src="/img/loader.gif" height="11" width="16" alt="Loading..." /&gt;';

    $form.append('&lt;div id="response" class="hidden"&gt;');
    var $response = $('#response');

    // Do what we need to when form is submitted.
    $form.on('click', 'input[type=submit]', function(e){

        // Hide any previous response text and show loader
        $response.hide().html( $loader ).show();

        // Make AJAX request 
        $.post('/resource/script/estimate-menu-send.php', $form.serialize(), function( data ) {

            // Show response message
            $response.html( data );

            // Scroll to bottom of the form to show respond message
            var bottomPosition = $form.offset().top + $form.outerHeight() - $(window).height();

            if( $(document).scrollTop() &lt; bottomPosition )
                $('html, body').animate({ scrollTop : bottomPosition });

            // If form has been sent succesfully, clear it
            if( data.indexOf('success') !== -1 )
                $form.find('input:not(input[type="submit"], input[type="reset"]), textarea, select').val('').attr( 'checked', false );

        });


        // Cancel default action
        e.preventDefault();
    });
});/*END FUNCTION*/
</code></pre>

<p>Here is the HTML for the header nav:</p>

<pre><code>&lt;div id="header-bottom"&gt;
    &lt;nav&gt;
      &lt;ul class="menu-option-set"&gt;
        &lt;li&gt;&lt;a href="/" &lt;?php echo $home ?&gt;&gt;Home&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#" data-subid="services"&lt;?php echo $services ?&gt;&gt;Services&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#" data-subid="gallery"&lt;?php echo $gallery ?&gt;&gt;Gallery&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#" data-subid="customer"&lt;?php echo $customer ?&gt;&gt;Customer&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#" data-subid="about"&lt;?php echo $about ?&gt;&gt;About&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#" data-subid="contact"&lt;?php echo $contact ?&gt;&gt;Contact&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#" data-subid="estimate"&lt;?php echo $estimate ?&gt;&gt;Estimate&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;form id="headerSearch" class="textcenter headerSearch" method="get"&gt;&lt;input id="headerInput" type="text" name="search"/&gt;&lt;/form&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/nav&gt;
  &lt;/div&gt;
  &lt;div id="header-subnav" class="hidden"&gt;
    &lt;nav&gt;
      &lt;ul id="services"&gt;
        &lt;li&gt;&lt;a href="/bathroom/"&lt;?php echo $bathroom ?&gt;&gt;Bathroom&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/kitchen/"&lt;?php echo $kitchen ?&gt;&gt;&lt;s&gt;Kitchen&lt;/s&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/accessibility/"&lt;?php echo $accessibility ?&gt;&gt;&lt;s&gt;Accessibility&lt;/s&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/window/"&lt;?php echo $window ?&gt;&gt;&lt;s&gt;Windows&lt;/s&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/deck/"&lt;?php echo $deck ?&gt;&gt;&lt;s&gt;Decks&lt;/s&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/siding/"&lt;?php echo $siding ?&gt;&gt;&lt;s&gt;Siding&lt;/s&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;ul id="gallery"&gt;
        &lt;li&gt;&lt;a href="/gallery.php"&lt;?php echo $photo ?&gt;&gt;Photo Gallery&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/project.php"&lt;?php echo $project ?&gt;&gt;Project Gallery&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/before-and-after.php" &lt;?php echo $before_and_after ?&gt;&gt;&lt;s&gt;Before &amp;amp; After&lt;/s&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;ul id="customer"&gt;
        &lt;li&gt;&lt;a href="/coupons.php"&lt;?php echo $coupons ?&gt;&gt;&lt;s&gt;Coupons&lt;/s&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/testimonials.php"&lt;?php echo $testimonials ?&gt;&gt;Testimonials&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/things-to-know.php"&lt;?php echo $things_to_know ?&gt;&gt;Things to Know&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/financing.php"&lt;?php echo $financing ?&gt;&gt;Financing&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/reviews.php"&lt;?php echo $reviews ?&gt;&gt;Reviews&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;ul id="about"&gt;
        &lt;li&gt;&lt;a href="/about.php"&lt;?php echo $about_us ?&gt;&gt;About Us&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/privacy.php"&lt;?php echo $privacy ?&gt;&gt;Privacy Policy&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/alliances.php"&lt;?php echo $alliances ?&gt;&gt;Strategic Alliances&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/certified-contractor.php"&lt;?php echo $certified_contractor ?&gt;&gt;Certified Contractor&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/awards-and-accreditations.php"&lt;?php echo $awards_and_accreditations ?&gt;&gt;Accreditations&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;ul id="contact"&gt;
        &lt;li&gt;&lt;a href="/contact.php"&lt;?php echo $contact_us ?&gt;&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/employment.php"&lt;?php echo $employment ?&gt;&gt;Employment&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="/estimate.php"&lt;?php echo $request_estimate ?&gt;&gt;Request Estimate&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;ul id="estimate"&gt;
        &lt;li&gt;Menu estimate Form coming soon&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/nav&gt;
  &lt;/div&gt;
</code></pre>

<p>Mind you, this all worked fine in IE9, but randomly broke, I didn't change the HTML, It must be something with the JS.</p>

<p>Thanks guys, I really appreciate it!</p>

<p><strong>EDIT: I'm sorry, I didn't even post the site that you could view the problem at.  It can be seen here: <a href="http://www.remodeling-buffalo.com" rel="nofollow">http://www.remodeling-buffalo.com</a></strong></p>
