【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 markets reddit <a href="https://heineken-drugs-online.com/ ">tfmpp pills </a> https://heineken-drugs-online.com/ - deep web drugs
名前
Michaelloush
darknet drug market <a href="https://heinekendarknetdrugstore.com/ ">what darknet market to use </a> https://heinekendarknetdrugstore.com/ - dark markets czech republic
名前
RichardDek
dark markets portugal <a href="https://darkweb-kingdom.com/ ">tor market list </a> https://darkweb-kingdom.com/ - dark web markets 2023
名前
Teddred
darknet union <a href="https://kingdomdarkmarketonline.com/ ">reddit darknetmarket </a> https://kingdomdarkmarketonline.com/ - darknet market xanax
名前
CharlesNuh
how big is the darknet market <a href="https://kingdomdarkwebdrugstore.com/ ">darknet market links </a> https://kingdom-darknet-drugstore.com/ - working darknet market links
名前
Julianacecy
deepdotweb markets <a href="https://kingdom-drugs-market.com/ ">darkmarket 2023 </a> https://kingdom-drugs-market.com/ - darknet websites drugs
名前
WilliamNaw
bitcoin darknet drugs <a href="https://heinekenmarketlink.com/ ">black market url deep web </a> https://heinekenmarket-url.com/ - dark markets austria
名前
BrandonWaype
versus project market url <a href="https://kingdomonionmarket.com/ ">darknet market credit cards </a> https://kingdom-online-drugs.com/ - reddit darknetmarket
名前
Ronaldevica
bitcoin drugs market <a href="https://heinekendrugsonline.com/ ">best australian darknet market </a> https://heinekendrugsonline.com/ - shop valid cvv
名前
Stevejails
how to darknet market <a href="https://darkfoxonlinedrugs.com/ ">best dark web search engine link </a> https://darkfoxonionmarket.com/ - Kingdom darknet Market
名前
Davidinodo
how to access deep web safely reddit <a href="https://heineken-darknet.com/ ">best dark web markets </a> https://heineken-darknet.com/ - dark web uk
名前
Michaeltus
online drug market <a href="https://heinekenoniondarkmarket.com/ ">dark markets romania </a> https://heinekenoniondarkweb.com/ - active darknet market urls
名前
RobertKix
dark web step by step <a href="https://heinekenurl.com/ ">uncensored deep web </a> https://heinekenmarketurl.com/ - best darknet market australia
名前
Charlescob
darknet markets fake id <a href="https://heinekenmarket-links.com/ ">darknet drugs </a> https://heinekenmarket-links.com/ - dark markets luxembourg
名前
Robertfup
Abacus darknet Market <a href="https://heinekendarkmarket.com/ ">darknet drugs sites </a> https://heinekendarkmarket.com/ - safe darknet markets
名前
DavidDes
hidden uncensored wiki <a href="https://dark-web-heineken.com/ ">darknet drugs price </a> https://dark-web-heineken.com/ - black market prescription drugs for sale
名前
HaroldHot
the darknet market reddit <a href="https://kingdomdarkmarket.com/ ">darknet markets with tobacco </a> https://kingdomdarkmarket.com/ - what are darknet drug markets
名前
Hanstulge
tor2door market darknet <a href="https://kingdom-marketplace.com/ ">cheapest drugs on darknet </a> https://darkfox-onion-darkweb.com/ - deep web weed prices
名前
WilliamRip
alphabay link reddit <a href="https://kingdomdarkweb.com/ ">live darknet markets </a> https://kingdomdarkweb.com/ - best darknet market for weed uk
名前
JamesHub
where to find darknet market links <a href="https://heineken-drugs-market.com/ ">adress darknet </a> https://heineken-drugs-market.com/ - alphabay market
名前
Brandendet
lsd drug wiki <a href="https://darkwebkingdom.com/ ">darknet guide </a> https://kingdom-onion.com/ - current darknet market list
名前
Danired
xanax darknet reddit <a href="https://heinekenexpressonion.com/ ">best dark web markets </a> https://heinekenexpressonion.com/ - alphabay market
名前
Dannyquord
fake id onion <a href="https://heinekennexpress.com/ ">onion link search engine </a> https://drheinekenexpress.com/ - dark market link
名前
Richardvak
best darknet markets for marijuana <a href="https://heinekenonionmarket.com/ ">top dumps shop </a> https://heinekenonionmarket.com/ - drug markets onion
名前
Edgarlow
tor top websites <a href="https://heinekenmarketdarknet.com/ ">darknet live stream </a> https://heinekenmarketdarknet.com/ - darkfox market url
名前
Josephanarm
darkmarket url <a href="https://kingdomonion.com/ ">tor2door link </a> https://kingdomonion.com/ - how to get to the black market online
名前
FrankHuluh
buds express <a href="https://heinekendarkwebdrugstore.com/ ">how to get on the dark web android </a> https://heineken-darknet-drugstore.com/ - deep web links updated
名前
HectorDer
deep web drug links <a href="https://darkmarketheineken.com/ ">how to access the dark web 2023 </a> https://heinekenonion.com/ - darknet markets list reddit
名前
ZacharyBop
reliable darknet markets lsd <a href="https://kingdom-onlinedrugs.com/ ">dark web cheap electronics </a> https://kingdom-onlinedrugs.com/ - how to get to the black market online
名前
Shanewat
deep website search engine <a href="https://kingdomdarkwebmarket.com/ ">darknet telegram group </a> https://kingdomdarkwebmarket.com/ - darknet market pills vendor
名前
Wendellpog
safe list of darknet market links <a href="https://heinekendrugsmarket.com/ ">darknet drug store </a> https://heinekendrugsmarketplace.com/ - largest darknet market
名前
MichaelRaf
deep dot web links <a href="https://kingdommarketplacee.com/ ">hitman for hire dark web </a> https://kingdommarketplacee.com/ - tor marketplaces
名前
Baaket
how to buy bitcoin and use on dark web <a href="https://heinekenmarketonlinee.com/ ">deep web updated links </a> https://heinekenn-express.com/ - dark web links 2023
名前
Patrickhuple
incognito market <a href="https://heinekendarknet.com/ ">counterfeit money onion </a> https://heinekendarkweb.com/ - access the dark web reddit
名前
JuliusEsobe
list of darknet markets reddit <a href="https://kingdom-darkwebmarket.com/ ">darknet escrow </a> https://kingdom-darkmarketplace.com/ - darknet market alaska
名前
JamesStaiz
best dark web markets 2023 <a href="https://heineken-express-onion.com/ ">darknet union </a> https://heineken-express-onion.com/ - onion marketplace drugs
名前
BrianFew
darknet market sites and how <a href="https://heineken-marketplace.com/ ">dark net markets </a> https://heineken-marketplace.com/ - darknet markets lsd-25 2023
名前
Georgelouse
dark markets san marino <a href="https://kingdommarketonlinee.com/ ">drugs sold on dark web </a> https://drkingdommarket.com/ - what bitcoins are accepted by darknet markets
名前
SmittMef
darknet list <a href="https://kingdomdarknetdrugstore.com/ ">dark markets italy </a> https://kingdomdarknetdrugstore.com/ - what darknet market to use now
名前
Geraldhopay
dark net market links 2023 <a href="https://heineken-darkmarket-online.com/ ">darknet market sites and how to access </a> https://heinekendarkmarketonline.com/ - underground dumps shop
名前
Randykew
dxm pills <a href="https://heineken-onion-darkmarket.com/ ">darknet market </a> https://heineken-onion-market.com/ - the real deal market darknet
名前
JackieDuart
deepdotweb markets <a href="https://kingdomoniondarkweb.com/ ">darknet live markets </a> https://kingdomoniondarkweb.com/ - darknet markets 2023 reddit
名前
CraigAgeni
darknet markets dread <a href="https://kingdomdrugsonline.com/ ">biggest darknet markets 2023 </a> https://kingdomonlinedrugs.com/ - dark web payment methods
名前
Davidjoisp
cypher link <a href="https://heineken-darkmarket.com/ ">Cocorico Market url </a> https://heinekendarkwebmarket.com/ - how to access the dark web through tor
名前
DonaldDic
how to access darknet markets reddit <a href="https://dark-market-heineken.com/ ">alphabay market url darknet adresse </a> https://dark-market-heineken.com/ - darknet market security
名前
Matthewgek
dark markets iceland <a href="https://kingdom-darkweb.com/ ">how to get on darknet market </a> https://kingdom-darknet.com/ - darknet сайты список
名前
Granttromo
reliable darknet markets reddit <a href="https://kingdomdarknetmarket.com/ ">australian dark web markets </a> https://darkfoxdarknetdrugstore.com/ - darknet live stream
名前
Crisscunc
best current darknet market <a href="https://heinekenmarketplacee.com/ ">site darknet fermГ© </a> https://heinekenmarketplacee.com/ - incognito darknet market
名前
Randytiz
monero darknet markets <a href="https://kingdom-markett.com/ ">what darknet markets are available </a> https://kingdom-markett.com/ - dark markets russia
名前
Tornaddib
alphabay url <a href="https://darkfox-onion-darkmarket.com/ ">biggest darknet market </a> https://darkfoxdarkwebdrugstore.com/ - deep web weed prices
名前
Jancal

コメントを追加

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