JavaScript implements a method that controls the opening of a file save as dialog

  • 2020-05-30 19:24:10
  • OfStack

The example in this article describes how JavaScript implements the control of opening file save as dialog box. Share with you for your reference. The details are as follows:

Here, JS opens the image save as dialog box to prompt the user to save the file

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script src="js/jquery.min.js" type="text/javascript"></script>
<script language="JavaScript">
function downLoadImage(imagePathURL){
// If the middle IFRAME Does not exist, adds 
jQuery('<iframe style="display:none;" id="_SAVEASIMAGE_TEMP_FRAME"
name="_SAVEASIMAGE_TEMP_FRAME" onload="_doSaveAsImage();"
width="0" height="0" src="about:blank"></iframe>').appendTo("body");
// The image address has changed. Load the image 
document.all._SAVEASIMAGE_TEMP_FRAME.src = imagePathURL;
// The image address does not change, save as directly 
function _doSaveAsImage(){
<input type="button" value="download image" 

I hope this article is helpful for you to design javascript program.

Related articles: