$(document).ready(function(){
setTimeout(function() {
window.location.href = $(".user a")[0].href;
}, 2000);
});
i put the above jquery code in a js file.which invoked by the site’s header template.but in some pages(there is no .user a) shows an error “0.href is null or not an object on IE status bar. how to prevent the error shows.
Check whwther there are any elements on the page which match the selector
.user a, before trying to read from the first one:As mentioned elsewhere, it might be a good idea to change that line also to: