警告 : Removed in Firefox 65.

download() 方法在 HTMLIFrameElement interface downloads a specified URL, storing it at /sdcard/download .

句法

var instanceOfDOMRequest =
instanceOfHTMLIframeElement.download(url, options);
					

返回

A DOMRequest for handling the download request. Its request.onsuccess handler handles the success case, and its request.onerror handler handles the failure case.

参数

url

The URL of the file to be downloaded.

选项 可选
An options object allowing optional settings to be specified for the download. The available options are:
  • filename : The filename to save the downloaded file as. If this is not specified, the filename used will be the original filename, as specified in the url .
  • referrer : Specifies a referrer for the downloaded file. If this is not specified there will be no referrer.

范例

var browser = document.querySelector('iframe');
var request = browser.download(fooURL, { filename: 'foo.bin' });
request.onsuccess = function() {
  console.log("File downladed");
}
request.onerror = function() {
  console.log("Download error");
}
					

规范

Not part of any specification.

浏览器兼容性

Supported since Firefox 47, in chrome code only. Removed completely in Firefox 65.

Unlikely ever to be supported in other browsers.

另请参阅

元数据

  • 最后修改:
  1. 方法
    1. HTMLIFrameElement.addNextPaintListener()
    2. HTMLIFrameElement.clearMatch()
    3. HTMLIFrameElement.download()
    4. HTMLIFrameElement.executeScript()
    5. HTMLIFrameElement.findAll()
    6. HTMLIFrameElement.findNext()
    7. HTMLIFrameElement.getActive()
    8. HTMLIFrameElement.getCanGoBack()
    9. HTMLIFrameElement.getCanGoForward()
    10. HTMLIFrameElement.getContentDimensions()
    11. HTMLIFrameElement.getMainfest()
    12. HTMLIFrameElement.getMuted()
    13. HTMLIFrameElement.getScreenshot()
    14. HTMLIFrameElement.getStructuredData()
    15. HTMLIFrameElement.goBack()
    16. HTMLIFrameElement.goForward()
    17. HTMLIFrameElement.getVisible()
    18. HTMLIFrameElement.getVolume()
    19. HTMLIFrameElement.mute()
    20. HTMLIFrameElement.purgeHistory()
    21. HTMLIFrameElement.reload()
    22. HTMLIFrameElement.removeNextPaintListener()
    23. HTMLIFrameElement.sendMouseEvent()
    24. HTMLIFrameElement.sendTouchEvent()
    25. HTMLIFrameElement.setActive()
    26. HTMLIFrameElement.setInputMethodActive()
    27. HTMLIFrameElement.setNFCFocus()
    28. HTMLIFrameElement.setVisible()
    29. HTMLIFrameElement.setVolume()
    30. HTMLIFrameElement.stop()
    31. HTMLIFrameElement.unmute()
    32. HTMLIFrameElement.zoom()
  2. 事件
    1. mozbrowseractivitydone
    2. mozbrowserasyncscroll
    3. mozbrowseraudioplaybackchange
    4. mozbrowsercaretstatechanged
    5. mozbrowserclose
    6. mozbrowsercontextmenu
    7. mozbrowserdocumentfirstpaint
    8. mozbrowsererror
    9. mozbrowserfindchange
    10. mozbrowserfirstpaint
    11. mozbrowsericonchange
    12. mozbrowserloadend
    13. mozbrowserloadstart
    14. mozbrowserlocationchange
    15. mozbrowsermanifestchange
    16. mozbrowsermetachange
    17. mozbrowseropensearch
    18. mozbrowseropentab
    19. mozbrowseropenwindow
    20. mozbrowserresize
    21. mozbrowserscroll
    22. mozbrowserscrollareachanged
    23. mozbrowserscrollviewchange
    24. mozbrowsersecuritychange
    25. mozbrowserselectionstatechanged
    26. mozbrowsershowmodalprompt
    27. mozbrowsertitlechange
    28. mozbrowserusernameandpasswordrequired
    29. mozbrowservisibilitychange