Add onload event to preview.html
Follow coding convention for js function names