2014-12-06 72 views
-1

編輯:它的github示例代碼我試圖去在IE9,你有你需要的一切,我已經展示了我已經嘗試過的例子,所以爲什麼要投票給我?閃存不會嵌入ie9

我正在使用這個簡單的github示例代碼來將一些數據保存在動態創建的彈出窗口中。閃存繞過了安全限制的保存,在Chrome和FireFox中運行良好。

在IE9(可能全部即是)瀏覽器要求保存swfobject.js,然後失敗。 這不是跨網站,它不是本地的,而是在一個普通的Apache服務器上。

https://github.com/gitbuh/bhd

的代碼是在該示例中的文件夾。

我已經嘗試了一些東西,比如用最新swfobject.js V2.2

替換它,並使用IE瀏覽器友好的文檔類型和元,但沒有運氣。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    <head> 
     <meta http-equiv="X-UA-Compatible" content="IE=9" /> 

我比較肯定的問題是在對嵌入的bhd.js,並且我已經設置玩耍了,但沒有運氣,這裏是bhd.js代碼:

/** BHD 

    Browser-Hosted Download 
*/ 
function BHD() { 
    return new BHD.Button(opts, callback); 
} 

BHD.uid = function() { 
    return 'x'+(+(''+Math.random()).substring(2)).toString(32)+(+new Date()).toString(32); 
}; 

BHD.getScriptPath = function() { 
    if (this.scriptPath) return this.scriptPath; 
    var scripts = document.getElementsByTagName('script'); 
    for (var i=scripts.length, m; i--;) { 
    if ((m=(''+scripts[i].src).match(/(.*\/?)bhd.js(\?|$)/))) { 
     return this.scriptPath = m[1] || ''; 
    } 
    } 
    return this.scriptPath = ''; 
} 

BHD.include = function (file, callback) { 
    var uid = BHD.uid(), frame; 
    frame = document.createElement('iframe'); 
    frame.src = file; 
    frame.id = frame.name = uid; 
    frame.onload = function() { 
    var s = document.getElementsByTagName('script')[0]; 
    var d = frames[uid].document.documentElement; 
    var script = document.createElement('script'); 
    script.type = 'text/javascript'; 
    script.text = d.textContent||d.innerText; 
    s.parentNode.insertBefore(script, s); 
    callback(); 
    s.parentNode.removeChild(s); 
    frame.parentNode.removeChild(frame); 
    } 
    document.documentElement.appendChild(frame); 
} 

/** BHD.Button 
*/ 
BHD.Button = function (opts, callback) { 

    this.opts = opts; 

    if (!opts) return; 

    this.setup(opts, callback); 

} 


/** setup 

    Embed the SWF object. 

    @param String opts 
*/ 
BHD.Button.prototype.setup = function (opts, callback) { 

    var button = this; 
    var flashvars = opts; 
    var params = { 
    quality: 'high', 
    wmode: 'transparent', 
    swLiveConnect: 'true', 
    menu: 'false', 
    scale: 'noScale', 
    allowFullscreen: 'true', 
    allowScriptAccess: 'always' 
    }; 
    var attributes = { id: opts.id, name: opts.id }; 

    this.opts = opts; 

    opts.callbackName = BHD.uid(); 

    window[opts.callbackName] = callback; 

    window[opts.callbackName + '_resize'] = function(w, h){ 
    object = button.getElement(); 
    object.style.width = w + 'px'; 
    object.style.height = h + 'px'; 
    }; 

    var cb = function(){ 
    swfobject.embedSWF(BHD.getScriptPath() + 'bhd.swf', 
     opts.id, '1', '1', '9.0.0', 
     null, flashvars, params, attributes); 
    } 

    if (typeof swfobject == 'undefined') { 
    BHD.include(BHD.getScriptPath() + 'swfobject.js', cb); 
    } else { 
    cb(); 
    } 

}; 


/** getElement 

    Get the embedded flash element, or element to be replaced 
    if swfobject.embedSWF has not finished yet. 

    @param String variable 
    @param Mixed value 
*/ 
BHD.Button.prototype.getElement = function() { 
    return document.getElementById(this.opts.id); 
}; 

/** setFile 

    Set the default filename to show in the save dialog. 

    @param String value 
*/ 
BHD.Button.prototype.setFile = function (value) { 
    return this.getElement().setFile(value); 
}; 

/** setData 

    Set the contents of the download file. 

    @param Mixed value 
*/ 
BHD.Button.prototype.setData = function (value) { 
    return this.getElement().setData(value); 
}; 

/** setUrl 

    Set the URL of the download file. 

    @param Mixed value 
*/ 
BHD.Button.prototype.setUrl = function (value) { 
    return this.getElement().setUrl(value); 
}; 

回答

0

看起來像bhd.js腳本不會在IE9中正確引導swfobject.js。 將此行添加到第4行的example/index.html,修復了IE9的問題。

<script src="../dist/swfobject.js"></script> 

在IE 10中證實了同樣的問題,此修復方法也適用。