Take image of my render with JS and save it

So after I have rendered my object, how can I make t so that when the page is loaded, it takes a image and saves it?

It should be as easy as passing the renderer to toDataURL and then passing the var to a new image.

renderer.render(scene, camera);
var imgData = renderer.domElement.toDataURL();
var img = new Image();
img.src = imgData;

Seems to be a duplicate of this stackoverflow thread:

@threejsisdope Please make sure to sufficiently search for existing answers before asking a new question.