sounds like you don't care about the content type, you just want a button that saves the page source as a file? (ie, replicating if the page had a header telling it to be downloaded?)
you can try something like this: (cross browser compatible, but will request permissions from users as this isn't a standard action, and I don't think you can get better than this🙂
<script language="JavaScript" type="text/javascript">
/* <![CDATA[ */
function saveAs ( )
{
if ( window.ActiveXObject )
{
document.execCommand( 'SaveAs' );
}
else if ( window.netscape )
{
var doc_range = document.createRange();
doc_range.setStartBefore( document.getElementsByTagName( 'head' )[0] );
var netscape_inbuilt_script = doc_range.createContextualFragment( "<script id='netscape_inbuilt' type='application/x-javascript' src='chrome://global/content/contentAreaUtils.js'><\/script>" );
document.body.appendChild( netscape_inbuilt_script );
doc_range = null;
try
{
netscape.security.PrivilegeManager.enablePrivilege( 'UniversalXPConnect' );
saveDocument( document );
}
catch ( e )
{
}
finally
{
var netscape_inbuilt_script = document.getElementById( 'netscape_inbuilt' );
netscape_inbuilt_script.parentNode.removeChild( netscape_inbuilt_script );
}
}
}
/* ]]> */
</script>
<a href='javascript:;' onclick='saveAs()'>Save Page</a>