I’m getting an error on ie8 for the following javascript:
<script type="text/javascript">
//when html doc is all ready
$(document).ready(function () {
var socket = io.connect();
var room = 'public';
socket.emit('join', room);
socket.on('message', function (data) {
var output = '';
output += '<div class="trace-content">';
output += ' <div class="mname">' + data.name + '</div>';
output += ' <div class="mdate">' + data.date + '</div>';
output += ' <p class="mtext">' + data.message + '</p>';
output += '</div>';
$(output).prependTo('#traces');
});
$('button').click(function () {
var date = new Date().toISOString();
socket.emit('message', {
name: $('#name').val(),
message: $('#message').val(),
date: date.slice(2,10) + ' ' + date.slice(11, 19)
});
});
});
</script>
The problem seems to be in the line: var date = new Date().toISOString();
I’m having trouble pin pointing what exactly the problem is.
Everything else seems to working fine; just that button click and the code following through. Any ideas?
IE8 doesn’t support
.toISOString(). You can use this code as a shim (from Mozilla) :