【JavaScript】IEの場合のdownload属性の代替

【JavaScript】IEの場合のdownload属性の代替

IEの場合、aタグのdownload属性が効かず、ファイルのダウンロードできなかったため、その代替案についての覚え書きです(Drupalネタではないです)。

download属性

Excelファイルをダウンロードできるように、以下のようなリンクを作成し、ファイルがダウンロードできることを確認していたのですが、


<a download="Test.xlsx" href="/download/Test.xlsx">Test.xlsx</a>

IEの場合、これではダウンロードできないとのことで、その対応結果を以下に記します。

JavaScriptでの対応

ググったところ、JavaScriptで画像をダウンロードしたいの記事によると、JavaScriptを使えば、IEでもリンクからファイルのダウンロードができるとのこと。

上記の記事を参考にして、以下のJavaScriptを記述。


function downloadFile(uri,fileName,id) {

    // IEはdownload属性が効かないので分岐
    if (window.navigator.msSaveOrOpenBlob) {
        let xhr = new XMLHttpRequest();
        xhr.open('GET', uri);
        xhr.responseType = 'blob';
        xhr.onloadend = function() {
            if (xhr.status !== 200) {
                return false;
            }
            window.navigator.msSaveOrOpenBlob(xhr.response, fileName);
        };
        xhr.send();
    } else {
        let link = document.getElementById(id);
        link.href = uri;
        link.download = fileName;
    }
}


HTMLは、以下のように記述を変更し、IEでもファイルをダウンロードできるようになりました。


<a id="download1" href="javascript:void(0);" onclick="downloadFile('/download/Test.xlsx','Test.xlsx','download1');">Test.xlsx</a>

カテゴリー

コメント

darknet drug vendors <a href="https://heinekendarknetdrugstore.com/ ">trusted darknet markets weed </a> https://heinekendarknetdrugstore.com/ - reddit darknet markets 2023
名前
RichardDek
dark markets albania <a href="https://heinekenoniondarkmarket.com/ ">darknet prices </a> https://heinekenoniondarkmarket.com/ - dark markets china
名前
RobertKix
vice city link <a href="https://heineken-drugs-online.com/ ">biggest darknet markets </a> https://heineken-onlinedrugs.com/ - darknet market ranking
名前
Michaelloush
black market webshop <a href="https://kingdom-drugsonline.com/ ">reddit working darknet markets </a> https://kingdom-drugs-market.com/ - history of darknet markets
名前
WilliamNaw
darknet market drug prices <a href="https://kingdomdarknetdrugstore.com/ ">best dark web markets 2023 </a> https://kingdom-onion-darkweb.com/ - drug markets onion
名前
Geraldhopay
shop valid cvv <a href="https://kingdom-markett.com/ ">illegal black market </a> https://kingdom-markett.com/ - reddit best darknet markets
名前
Tornaddib
dark markets bulgaria <a href="https://kingdomonionmarket.com/ ">onion tube porn </a> https://kingdomonionmarket.com/ - best dark web markets
名前
Ronaldevica
how to access darknet market <a href="https://kingdomdarknet.com/ ">incognito market darknet </a> https://kingdomdarknet.com/ - naked lady ecstasy pill
名前
JamesHub
dark web xanax <a href="https://darkmarket-heineken.com/ ">onion websites for credit cards </a> https://darkmarket-heineken.com/ - bitcoins and darknet markets
名前
HaroldHot
darknet market noobs <a href="https://heinekenexpressonion.com/ ">vice city darknet market </a> https://heineken-onion.com/ - new darknet market reddit
名前
Dannyquord
dark web steroids <a href="https://heinekenmarket-links.com/ ">best darknet markets uk </a> https://heinekenmarket-link.com/ - black market url deep web
名前
Robertfup
ruonion <a href="https://kingdomdarkmarket.com/ ">deep cp links </a> https://kingdomdarkmarket.com/ - link de hiden wiki
名前
Hanstulge
darknet drugs links <a href="https://kingdommarketlink.com/ ">new onion darknet market </a> - dark web cheap electronics
名前
ADElugh
carding dark web <a href="https://kingdomonion.com/ ">darknet marketplace </a> https://kingdomonion.com/ - what are darknet drug markets
名前
FrankHuluh
darkmarket url <a href="https://heinekennexpress.com/ ">cypher market </a> https://drheinekenexpress.com/ - deep web drug prices
名前
Richardvak
berlin telegram group drugs <a href="https://darkweb-kingdom.com/ ">best darknet market for guns </a> https://darkweb-kingdom.com/ - reliable darknet markets reddit
名前
Teddred
dark markets norway <a href="https://kingdomdarknetmarket.com/ ">bitcoin dark website </a> https://kingdomdarknetmarket.com/ - dark markets japan
名前
Crisscunc
deep web marketplaces reddit <a href="https://kingdom-onion-darkmarket.com/ ">buy darknet market email address </a> https://kingdom-onion-darkmarket.com/ - best darknet market uk
名前
DamonLat
0day onion <a href="https://heinekenonion.com/ ">fake id dark web 2023 </a> https://heinekenonion.com/ - dark markets china
名前
ZacharyBop
Abacus Market darknet <a href="https://heineken-express-onion.com/ ">darknet drug links </a> https://darkwebheineken.com/ - dark markets finland
名前
BrianFew
drugs sold on dark web <a href="https://kingdomdarkwebmarket.com/ ">new darknet markets </a> https://kingdom-darkmarket.com/ - what bitcoins are accepted by darknet markets
名前
Wendellpog
dark markets estonia <a href="https://heinekendarknetmarket.com/ ">darkshades marketplace </a> https://heinekenmarketdarknet.com/ - darknet market wiki
名前
Josephanarm
deep dot web replacement <a href="https://kingdommarketplacee.com/ ">the dark web links 2023 </a> https://kingdommarketplacee.com/ - Kingdom link
名前
Baaket
dark net market links 2023 <a href="https://heineken-drugs-market.com/ ">wired darknet markets </a> https://heineken-drugs-market.com/ - darknet websites wiki
名前
Brandendet
best darknet market reddit <a href="https://heinekendarkmarket.com/ ">how to access dark web markets </a> https://heinekenmarket-online.com/ - google black market
名前
DavidDes
how to use deep web on pc <a href="https://heinekendarknet.com/ ">darknet market noobs </a> https://heinekendarkweb.com/ - darknet adress
名前
JuliusEsobe
<a href="https://k-tv.ru/">k-tv.ru</a>
名前
bbxoeldu
dark markets estonia <a href="https://heinekenmarketonlinee.com/ ">buying credit cards on dark web </a> https://heinekenn-express.com/ - alpha market url
名前
Patrickhuple
dark web prostitution <a href="https://kingdom-drugs-online.com/ ">best darknet market urs </a> https://kingdom-onlinedrugs.com/ - new darknet markets
名前
Shanewat
darknet market dmt <a href="https://kingdommarket-darknet.com/ ">bohemia url </a> https://kingdommarket-links.com/ - darkmarkets
名前
CorryViarD
i2p darknet markets <a href="https://kingdomurl.com/ ">dxm pills </a> https://kingdomurl.com/ - dark markets estonia
名前
Hellyzes
darknet market news <a href="https://heinekenmarketplace24.com/ ">pill with crown on it </a> https://heinekenmarketplace24.com/ - top 10 dark websites
名前
Georgelouse
onion directory 2023 <a href="https://kingdom-onion.com/ ">dark web search engine 2023 </a> https://darkwebkingdom.com/ - darknet markets address
名前
Danired
best market darknet drugs <a href="https://dark-market-heineken.com/ ">reddit darknet market uk </a> https://dark-market-heineken.com/ - decentralized darknet market
名前
Matthewgek
current best darknet market <a href="https://heineken-darkmarket-online.com/ ">dark web markets reddit 2023 </a> https://heinekendarkmarketonline.com/ - dark web sites drugs
名前
Randykew
deep web drug url <a href="https://heinekendrugsmarketplace.com/ ">darknet market controlled delivery </a> https://heinekendrugsmarket.com/ - darknet market forum
名前
MichaelRaf
dark markets albania <a href="https://kingdom-darkwebmarket.com/ ">underground website to buy drugs </a> https://kingdom-darkwebmarket.com/ - darknet market alternatives
名前
JamesStaiz
dark markets south korea <a href="https://heinekendarkmarketplace.com/ ">cypher market url </a> https://heineken-dark-market.com/ - versus project market url
名前
TimmyMeexy
how to access the dark web through tor <a href="https://drkingdommarket.com/ ">dark web market reviews </a> https://drkingdommarket.com/ - darknet market noobs
名前
SmittMef
guide to darknet markets <a href="https://kingdom-darknet-drugstore.com/ ">dark markets liechtenstein </a> https://kingdomdarkwebdrugstore.com/ - darknet markets may 2023
名前
Julianacecy
drug markets onion <a href="https://kingdom-darknet.com/ ">buying drugs online </a> https://kingdom-darknet.com/ - deep web links reddit 2023
名前
Granttromo
darknet telegram group <a href="https://heinekendarkwebmarket.com/ ">trusted darknet vendors </a> https://heinekendarkwebmarket.com/ - best website to buy cc
名前
DonaldDic
darknet markets guide <a href="https://heineken-darknet-drugstore.com/ ">darknet market package </a> [url=https://heinekendarkwebdrugstore.com/ ]best lsd darknet market [/url]
名前
HectorDer
best darknet markets uk <a href="https://kingdomdrugsonline.com/ ">darknet market stats </a> https://kingdomonlinedrugs.com/ - which darknet markets are still open
名前
Davidjoisp
dark web payment methods <a href="https://kingdomoniondarkmarket.com/ ">reddit best darknet market </a> https://kingdomoniondarkweb.com/ - dark markets new zealand
名前
CraigAgeni
best darknet market for psychedelics <a href="https://heinekenmarketplacee.com/ ">crypto darknet drug shop </a> https://kingdom-darkweb-drugstore.com/ - deep net access
名前
Randytiz
counterfeit money dark web reddit <a href="https://heineken-markett.com/ ">best dark web counterfeit money </a> https://heineken-markett.com/ - wiki darknet market
名前
JamesseM
site onion liste <a href="https://heinekenonionmarket.com/ ">darknet market carding </a> https://heinekenonionmarket.com/ - dark markets south korea
名前
Edgarlow
how to buy drugs on darknet <a href="https://heineken-darkwebmarket.com/ ">deep web drug store </a> https://heineken-darkmarketplace.com/ - darknet сайты список
名前
JasonGribe
dark markets turkey <a href="https://heineken-onion-market.com/ ">fresh onions link </a> https://heineken-onion-market.com/ - 2023 working darknet market
名前
JackieDuart

コメントを追加

CAPTCHA
この質問はあなたが人間の訪問者であるかどうかをテストし、自動化されたスパム送信を防ぐためのものです。
画像CAPTCHA
画像内に表示されている文字列を入力してください。