I am trying to resolve an odd javascript issue where a script works perfectly in all browsers - except IE, but works the moment you open the dev tools.
I have searched around and this is often due to IE not spawning the console object. However, there is no mention of console in the code and I have tried 5+ different codes that apparently prevent this problem, to no avail.
I'd appreciate some help figure this one out!
Code:
var slide = function slider() {
var i = 0;
var slider = {
loop: function loop(data) {
$.getJSON('?getdata=1', function(data) {
var create = $('<div class="social-area pic">' + '<div class="socimgdiv">' + '<img class="socimg" src="' + data.pic + '">' + '<div class="infotxt">' + data.name + '<br><small>' + data.age + ', ' + data.country + '</small><br>' + '</div></div></div>'),
maxTimeout = 4000,
minimumTimeout = 1000;
$('#box').prepend(create);
$('.social-area').last().fadeOut(400);
setTimeout(function() {
$('.social-area').last().remove();
}, 400);
setTimeout(function() {
$('.pic').animate({
width: 'toggle'
}, 350).removeClass('pic');
}, 400);
i += 1;
if (i >= 5) {
timeouter = Math.floor(Math.random() * maxTimeout);
if (timeouter <= minimumTimeout) timeouter = minimumTimeout;
} else timeouter = 400;
setTimeout(function() {
this.loop();
}.bind(slider), timeouter);
});
}
};
slider.loop();
};
slide();
The script collects data from a JSON feed which is generated via a PHP script included earlier:
if(isset($_GET['getdata'])){
echo json_encode(array(
'name' => $name,
'gender' => $gender,
'age' => $age,
'country' => $mycountry,
'pic' => $pic
)); exit;
}
This all works fine - exactly as expected in FF, Chrome, Safari and Opera - but not in IE 11 with the developer tools unopened.
Presumably there is some call or function that doesn't work before spawning the console object but I have no idea what it is!
if (typeof console == 'undefined') {console = {}}; if (!console.log) {console.log = function (){}};