Fix bug of javascript not working after a page rendering