Tuesday, December 7, 2010

JavaScript: Use ExecCommand to Create a Save Button

I was asked to do this today, a client had a framed Web site and wanted to have a "Save" button on one of the frames since whenever someone used the File > Save button, it saved the entire frameset.  This is what I did and it can be used in just about any situation.

In the head of the document:

<SCRIPT Language="Javascript">
function saveitup()
{
document.execCommand('SaveAs');
}
</script>

Where you want the button to be on the page:

<a href="javascript:saveitup()" title="Save this article to your hard drive.">Save</a>

No comments:

Post a Comment