Fixed javascript error when no file or no read permission