I’m trying to A/B test our product drop view. below is the javascript code I’m using:
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;
}
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 & 8
How can I fix this?
I was able to resolve the problem. and for future reference I’ll post some code and explain.
The offending code looks like this:
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 adomreadyevent which adds hover events to our navigtaion(which is incidentally below mymboxCreate()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 theobject does not support this method or propertyerrors.The solution to the problem was to remove all
domreadyevents before I redirected so my error free code looks like this: