Fix javascript for Chrome and IE