using method to display image into javascript