【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 market reviews <a href="https://kingdomonion.com/ ">new darknet markets </a> https://kingdomonion.com/ - darknet search engine
名前
FrankHuluh
hire an assassin dark web <a href="https://heinekendarkwebdrugstore.com/ ">wired darknet markets </a> https://heineken-darknet-drugstore.com/ - dark markets russia
名前
HectorDer
darknet credit card market <a href="https://heinekennexpress.com/ ">dark markets poland </a> https://heinekennexpress.com/ - working darknet market links
名前
Richardvak
active darknet markets <a href="https://heinekenexpressonion.com/ ">how to search the dark web reddit </a> https://heineken-onion.com/ - darknet markets 2023 updated
名前
Dannyquord
verified dark web links <a href="https://heinekenmarketdarknet.com/ ">pink versace pill </a> https://heinekenmarketdarknet.com/ - drug markets onion
名前
Josephanarm
Cocorico url <a href="https://dark-market-kingdom.com/ ">dark web counterfeit money </a> https://dark-market-kingdom.com/ - darknet market thc oil
名前
Teddred
deep onion links <a href="https://darkmarketheineken.com/ ">black market prescription drugs for sale </a> https://heinekenonion.com/ - darkweb market
名前
ZacharyBop
biggest darknet market 2023 <a href="https://kingdom-onlinedrugs.com/ ">black market url deep web </a> https://kingdom-onlinedrugs.com/ - the dark web shop
名前
Shanewat
links da deep web 2023 <a href="https://kingdomdarkwebmarket.com/ ">deep web updated links </a> https://kingdomdarkwebmarket.com/ - step by step dark web
名前
Wendellpog
carding deep web links <a href="https://heinekendrugsmarketplace.com/ ">reddit darknet market australia </a> https://heinekendrugsmarket.com/ - darknet market url
名前
MichaelRaf
dark web steroids <a href="https://heinekenmarketonlinee.com/ ">superlist darknet markets </a> https://heinekenmarketonlinee.com/ - onion darknet market
名前
Patrickhuple
dark web links 2023 reddit <a href="https://kingdom-darkwebmarket.com/ ">darknet sites </a> https://kingdom-darkmarketplace.com/ - back market trustworthy
名前
JamesStaiz
tor link list 2023 <a href="https://heinekendarknet.com/ ">list of darknet drug markets </a> https://heinekendarkweb.com/ - weed only darknet market
名前
JuliusEsobe
deep web drug store <a href="https://drkingdommarket.com/ ">darknet guns market </a> https://drkingdommarket.com/ - best card shops
名前
SmittMef
black market prescription drugs <a href="https://kingdomdarkwebdrugstore.com/ ">we amsterdam </a> https://kingdom-darknet-drugstore.com/ - dark markets canada
名前
Julianacecy
dark market links <a href="https://heineken-onion-darkmarket.com/ ">biggest darknet markets </a> https://heineken-onion-market.com/ - tor onion search
名前
JackieDuart
dark web cvv <a href="https://heineken-express-onion.com/ ">deep web cc sites </a> https://heineken-express-onion.com/ - tor marketplace
名前
BrianFew
darknet market <a href="https://heinekenmarketplace24.com/ ">darknet adressen </a> https://heinekenmarketplace24.com/ - darknet market list
名前
Georgelouse
active darknet market urls <a href="https://heinekendarkmarketonline.com/ ">can you buy drugs on darknet </a> https://heineken-darkmarket-online.com/ - darknet market lightning network
名前
Randykew
buying drugs off darknet <a href="https://darkwebkingdom.com/ ">darknet site </a> https://darkwebkingdom.com/ - where to find darknet market links
名前
Danired
top ten deep web <a href="https://darkfoxonlinedrugs.com/ ">how to buy things off the black market </a> https://darkfoxonlinedrugs.com/ - darknet prices
名前
Davidinodo
dark markets monaco <a href="https://kingdomoniondarkweb.com/ ">fake id onion </a> https://kingdomoniondarkmarket.com/ - darknet markets 2023
名前
CraigAgeni
onion sex shop <a href="https://dark-market-heineken.com/ ">darknet market alphabay </a> https://darkweb-heineken.com/ - darknet market url
名前
Matthewgek
working darknet markets <a href="https://heineken-darkmarket.com/ ">darknet drug links </a> https://heineken-darkmarket.com/ - search deep web engine
名前
DonaldDic
best current darknet market <a href="https://kingdom-darknet.com/ ">live dark web </a> https://kingdom-darkweb.com/ - reddit darknet market uk
名前
Granttromo
how to get to darknet market safe <a href="https://kingdomonlinedrugs.com/ ">safe darknet markets </a> https://kingdomdrugsonline.com/ - darknet market ranking
名前
Davidjoisp
darknet market onion links <a href="https://kingdom-darkweb-drugstore.com/ ">adresse onion </a> https://kingdom-darkweb-drugstore.com/ - Abacus Market url
名前
Randytiz
darknet market url list <a href="https://heineken-dark-market.com/ ">underground market online </a> https://heineken-dark-market.com/ - dark web market
名前
TimmyMeexy
popular dark websites <a href="https://kingdomdrugsmarket.com/ ">dark web sites links </a> https://kingdomdrugsmarketplace.com/ - how to access dark web markets
名前
Sirket
buy bank accounts darknet <a href="https://heineken-onlinedrugs.com/ ">how to use the darknet markets </a> https://heineken-drugs-online.com/ - tor2door darknet market
名前
Michaelloush
darknet market wikia <a href="https://heineken-darkmarketplace.com/ ">tor top websites </a> https://heineken-darkwebmarket.com/ - onion marketplace drugs
名前
JasonGribe
darknet xanax <a href="https://kingdomdarknetmarket.com/ ">dark web sites drugs </a> https://kingdomdarknetmarket.com/ - top darknet market 2023
名前
Crisscunc
deep web links 2023 reddit <a href="https://heineken-onion-darkweb.com/ ">links da deep web 2023 </a> https://heineken-onion-darkweb.com/ - best darknet market for weed uk
名前
RichardDek
reliable darknet markets <a href="https://kingdomdarkmarketonline.com/ ">what is escrow darknet markets </a> https://kingdomdarkmarketonline.com/ - red ferrari pills
名前
CharlesNuh
incognito market url <a href="https://kingdom-dark-market.com/ ">how to darknet market </a> https://kingdom-dark-market.com/ - darknet sites
名前
Ralphzet
darknet sites <a href="https://kingdom-drugs-market.com/ ">best market darknet drugs </a> https://kingdom-drugsonline.com/ - dark markets argentina
名前
WilliamNaw
active darknet markets 2023 <a href="https://kingdom-online-drugs.com/ ">darknet onion markets </a> https://kingdom-online-drugs.com/ - dark markets brazil
名前
Ronaldevica
tor market list <a href="https://kingdom-marketplace.com/ ">ethereum darknet markets </a> https://darkfox-onion-darkweb.com/ - drug website dark web
名前
WilliamRip
darknet links market <a href="https://heinekenmarketlink.com/ ">wired darknet markets </a> https://heinekenmarketlink.com/ - Cocorico darknet Market
名前
BrandonWaype
onion link search engine <a href="https://kingdommarketplacee.com/ ">legit darknet sites </a> https://kingdommarketplacee.com/ - deep dark web markets links
名前
Baaket
alphabay market url darknet adresse <a href="https://heinekenoniondarkweb.com/ ">unicorn pill </a> https://heinekenoniondarkweb.com/ - black market websites 2023
名前
RobertKix
link de hiden wiki <a href="https://heinekenonlinedrugs.com/ ">versus project market </a> https://heinekendrugsonline.com/ - deep web drug links
名前
Stevejails
can you buy drugs on darknet <a href="https://kingdom-markett.com/ ">darkweb marketplace </a> https://kingdommarketdarknet.com/ - links da deep web 2023
名前
Tornaddib
biggest darknet markets 2023 <a href="https://darkfoxdarkwebdrugstore.com/ ">dark markets bulgaria </a> https://darkfoxdarkwebdrugstore.com/ - darknet black market sites
名前
Jancal
Abacus Market link <a href="https://heineken-darknet.com/ ">bohemia darknet market </a> https://heineken-darkweb.com/ - drugs on the dark web
名前
Michaeltus
reddit darknet market 2023 <a href="https://heinekenmarketurl.com/ ">tor market links </a> https://heinekenurl.com/ - search darknet market
名前
Charlescob
how to order from dark web <a href="https://heinekenmarket-links.com/ ">russian darknet market </a> https://heinekenmarket-link.com/ - best lsd darknet market
名前
Robertfup
dark markets estonia <a href="https://kingdomdarkmarket.com/ ">dark markets norway </a> https://kingdommarket-online.com/ - dark web market
名前
Hanstulge
decentralized darknet market <a href="https://dark-web-heineken.com/ ">australian dark web markets </a> https://dark-web-heineken.com/ - darknet market links 2023
名前
HaroldHot
darknet market link updates <a href="https://heinekendarkmarket.com/ ">onion directory 2023 </a> https://heinekenmarket-online.com/ - escrow market darknet
名前
DavidDes

コメントを追加

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