Code for save button to save .jpg file to machine


On my website, I am creating a canvas element, where user has option to select background and text,if we right click this element and save it, it gets saved to machine properly.However I want to avoid asking user to rt click and save it, instead how can I implement a code for save button where that canvas element can be saved on machine.

Any help will be appreciated?:rolleyes:
I can give you page url if required.