Dynamic javascript working in the browser