Javascript redirect causing IE 'null' is null or not an object error
<p>I'm trying to A/B test our product drop view.  below is the javascript code I'm using: 
<code></p>

<pre>
  var url = window.location.href,
      defaultType = 'Gallery',
      otherType = 'List';
  if(Cookie.read('SEARCHVIEW') == otherType && Cookie.read('viewTypeChanged') != otherType){
      if(url.contains('v='+otherType)){
        url = url.replace('v='+otherType, 'v='+defaultType);
      }else if(url.contains('?')){
        url = url + '&v='+defaultType;
      }else{
        url = url + '?v='+defaultType;
      }

      window.location = url;
    }
</pre>

<p></code>
After the page redirects in IE I get the dreaded "'null' is null or not an object" and 'Object does not support this property or method' errors.
This is happening in both IE 7 &amp; 8
Any help would be great.
Thanks</p>

<p>Update</p>

<hr>

<p>I was able to resolve the problem. and for future reference I'll post some code and explain.
The offending code looks like this:
<code></p>

<pre>
&lt;script type="text/javascript"&gt;

 window.addEvent('domready', function(){


  $('v_toggle').addEvents({
   'mouseenter': function(e){
   $('vertical_slide_container').show();

  },
   'mouseleave': function(e){
   $('vertical_slide_container').hide();

  }
  });
 });
 &lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;


&lt;div class="mboxDefault"&gt;/div&gt;
&lt;script type="text/javascript"&gt;mboxCreate('header',etc...);&lt;/script&gt;

</pre>

<p></code></p>

<p>My company uses Omniture for our A/B testing and my code was being run in the mboxCreate() function.  You'll notice above that there is code adding a domready event which adds hover events to our navigtaion(which is incidentally below my mboxCreate() code).  What was happening was my code was redirecting, which stopped the page from loading, which also signaled that the DOM was ready.  So when I called the redirect, the DOM ready code was run and was trying to add hover events on DOM elements that did not exists. Thus the "'null' is null or not an object' and the 'object does not support this method or propery' errors.</p>

<p>The solution to the problem was to remove all domready events before I redirected so my error free code looks like this:
<code></p>

<pre>
  var url = window.location.href,
      defaultType = 'Gallery',
      otherType = 'List';
  if(Cookie.read('SEARCHVIEW') == otherType && Cookie.read('viewTypeChanged') != otherType){
      if(url.contains('v='+otherType)){
        url = url.replace('v='+otherType, 'v='+defaultType);
      }else if(url.contains('?')){
        url = url + '&v='+defaultType;
      }else{
        url = url + '?v='+defaultType;
      }
      window.removeEvents('domready');
      window.location = url;
    }
</pre>

<p></code></p>

<p>I'm not sure how to proceed since I was able to find the solution to my own question.</p>
