Don't use split()
method, use match()
instead.
$(document).ready(function() {
var arr = location.search.match(/[?&]id=(\d+)/i);
if (arr && arr[1] > 0) {
$('#myModal').modal('show');
}
else
{
location.href="/";
}
});