Commit 566bd6d7 authored by Akikonata's avatar Akikonata

test

parent dcebf9b5
...@@ -34,12 +34,6 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -34,12 +34,6 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var a = document.createElement( 'a' ); var a = document.createElement( 'a' );
a.setAttribute( 'download', filename ); a.setAttribute( 'download', filename );
a.setAttribute( 'href', url ); a.setAttribute( 'href', url );
a.innerText = '我是一个下载链接';
a.style.position = 'absolute';
a.style.zIndex = 99999999;
a.style.left = 0;
a.style.top = 0;
document.body.appendChild( a );
var evt; var evt;
try { try {
evt = new MouseEvent( 'click' ); evt = new MouseEvent( 'click' );
...@@ -57,6 +51,15 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -57,6 +51,15 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
if ( typeof ( data ) == 'string' ) { if ( typeof ( data ) == 'string' ) {
var url = 'data:text/plain; utf-8,' + encodeURIComponent( data ); var url = 'data:text/plain; utf-8,' + encodeURIComponent( data );
doDownload( url, filename ); doDownload( url, filename );
if ( navigator.userAgent.indexOf( "MSIE" ) > 0 ) {
var iframe = document.createElement( 'iframe' );
//iframe.style.display = 'none';
document.appendChild( iframe );
iframe.src = filename;
iframe.contentDocument.body.innerHTML = data;
document.execCommand( "SaveAs" );
document.removeChild( iframe );
}
} else if ( data && data.then ) { } else if ( data && data.then ) {
data.then( function ( url ) { data.then( function ( url ) {
doDownload( url, filename ); doDownload( url, filename );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment