【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 dmt <a href="https://heinekenmarketlink.com/ ">deep web marketplaces reddit </a> https://heinekenmarketlink.com/ - darknet drug vendor that takes paypal
名前
BrandonWaype
darknet market drug prices <a href="https://heineken-darkweb.com/ ">biggest darknet market 2023 </a> https://heineken-darknet.com/ - back market legit
名前
Michaeltus
site darknet fermГ© <a href="https://heineken-online-drugs.com/ ">online black market electronics </a> https://heinekenonionmarket.com/ - tor marketplace
名前
Edgarlow
darknet market alternatives <a href="https://heinekenmarketurl.com/ ">dark markets netherlands </a> https://heinekenmarketurl.com/ - onion deep web wiki
名前
Charlescob
reddit darknet market list 2023 <a href="https://kingdommarket-online.com/ ">what darknet markets still work </a> https://kingdommarket-online.com/ - darknet drugs price
名前
Hanstulge
best darknet market for counterfeit <a href="https://heineken-drugs-market.com/ ">project versus </a> https://heineken-drugsonline.com/ - dark websites reddit
名前
Brandendet
best dark web search engine link <a href="https://darkmarketkingdom.com/ ">dumps shop </a> https://darkmarketkingdom.com/ - onion links for deep web
名前
FrankHuluh
darknet market reviews <a href="https://kingdomdarknet.com/ ">tor markets links </a> https://kingdomdarkweb.com/ - darknet сайты список
名前
JamesHub
current darknet market <a href="https://drheinekenexpress.com/ ">how to use deep web on pc </a> https://heinekennexpress.com/ - dark web step by step
名前
Richardvak
current darknet markets reddit <a href="https://heinekendarkmarket.com/ ">dumps shop </a> https://heinekendarkmarket.com/ - bohemia link
名前
DavidDes
darknet dream market link <a href="https://darkmarket-heineken.com/ ">onion directory </a> [url=https://dark-web-heineken.com/ ]darknet drug vendor that takes paypal [/url]
名前
HaroldHot
how to get to the black market online <a href="https://kingdommarketplacee.com/ ">new darknet markets 2023 </a> https://darkfox-onlinedrugs.com/ - history of darknet markets
名前
Baaket
dark markets bulgaria <a href="https://heinekenmarket-link.com/ ">online black market uk </a> https://heinekenmarket-links.com/ - dark web electronics
名前
Robertfup
bitcoin darknet markets <a href="https://kingdommarket-url.com/ ">xanax darknet markets reddit </a> - darknet market credit cards
名前
ADElugh
darknet list market <a href="https://heinekenexpressonion.com/ ">drug markets dark web </a> https://heinekenexpressonion.com/ - dark markets uruguay
名前
Dannyquord
dark web sales <a href="https://kingdomurl.com/ ">darknet selling drugs </a> https://kingdommarketurl.com/ - underground hackers black market
名前
Hellyzes
florida darknet markets <a href="https://heinekenmarketdarknet.com/ ">best darknet markets uk </a> https://heinekenmarketdarknet.com/ - bitcoin black market
名前
Josephanarm
black market webshop <a href="https://heinekenonion.com/ ">dark web buy credit cards </a> https://darkmarketheineken.com/ - reddit darknet market how to
名前
ZacharyBop
counterfeit money dark web reddit <a href="https://heinekendrugsmarket.com/ ">dark markets andorra </a> https://heinekendrugsmarket.com/ - darknet market wiki
名前
MichaelRaf
the dark web url <a href="https://dark-web-kingdom.com/ ">alpha market url </a> https://dark-web-kingdom.com/ - dn market
名前
Danielred
pink versace pill <a href="https://kingdommarketdarknet.com/ ">trusted darknet vendors </a> https://kingdommarketdarknet.com/ - darknet markets urls
名前
Tornaddib
monero darknet market <a href="https://kingdom-drugs-online.com/ ">dark web search tool </a> https://kingdom-drugs-online.com/ - search deep web engine
名前
Shanewat
dark web weed <a href="https://kingdomdarkwebmarket.com/ ">how to buy drugs on darknet </a> https://kingdomdarkwebmarket.com/ - hidden wiki tor onion urls directories
名前
Wendellpog
drugs from darknet markets <a href="https://kingdom-darkmarketplace.com/ ">dark web poison </a> https://kingdom-darkmarketplace.com/ - best darknet market for weed 2023
名前
JamesStaiz
darknet drugs market <a href="https://heinekenn-express.com/ ">what darknet markets are available </a> https://heinekenmarketonlinee.com/ - dark markets ecuador
名前
Patrickhuple
best lsd darknet market <a href="https://heineken-onion-darkmarket.com/ ">darknet market news </a> https://heineken-onion-darkmarket.com/ - how to access the dark web safely reddit
名前
JackieDuart
black market websites 2023 <a href="https://drkingdommarket.com/ ">darknet drug store </a> https://drkingdommarket.com/ - dark markets guyana
名前
SmittMef
Kingdom Market darknet <a href="https://heineken-express-onion.com/ ">versus darknet market </a> https://heineken-express-onion.com/ - versus darknet market
名前
BrianFew
ethereum darknet markets <a href="https://heinekenmarketplace24.com/ ">reddit darknet market noobs bible </a> https://heinekenmarketplace24.com/ - reddit darknet market how to
名前
Georgelouse
hidden financial services deep web <a href="https://heineken-darkmarket-online.com/ ">Kingdom link </a> https://heineken-darkmarket-online.com/ - darknet escrow
名前
Randykew
dark web search tool <a href="https://kingdomonlinedrugs.com/ ">dark markets chile </a> https://kingdomdrugsonline.com/ - how to buy from darknet
名前
Davidjoisp
dark markets moldova <a href="https://kingdomdarknetdrugstore.com/ ">drugs on deep web </a> https://kingdomdarknetdrugstore.com/ - darknet market listing
名前
Geraldhopay
dark web hitman for hire <a href="https://kingdomoniondarkmarket.com/ ">darknet market deep dot web </a> https://kingdomoniondarkweb.com/ - how to order from dark web
名前
CraigAgeni
Abacus Market link <a href="https://darkfox-onion-darkmarket.com/ ">biggest darknet markets 2023 </a> https://darkfox-onion-darkmarket.com/ - reddit best darknet markets
名前
Jancal
list of darknet drug markets <a href="https://darkweb-kingdom.com/ ">the darknet drugs </a> https://darkweb-kingdom.com/ - dark markets monaco
名前
Teddred
dark markets usa <a href="https://heineken-onlinedrugs.com/ ">archetyp url </a> https://heineken-onlinedrugs.com/ - most popular darknet markets 2023
名前
Michaelloush
best drug darknet <a href="https://heineken-darkmarket.com/ ">asap market link </a> https://heineken-darkmarket.com/ - dark web cheap electronics
名前
DonaldDic
blue lady e pill <a href="https://heinekenmarketplacee.com/ ">cypher market darknet </a> https://kingdom-darkweb-drugstore.com/ - dark web sites links
名前
Randytiz
phenazepam pills <a href="https://kingdom-darkweb.com/ ">darknet market adderall prices </a> https://kingdom-darknet.com/ - legit darknet sites
名前
Granttromo
weed only darknet market <a href="https://kingdomdrugsmarketplace.com/ ">dma drug </a> https://kingdomdrugsmarketplace.com/ - darkshades marketplace
名前
Sirket
darknet drugs url <a href="https://darkweb-heineken.com/ ">archetyp market </a> https://dark-market-heineken.com/ - darknet new market link
名前
Matthewgek
dark web links reddit <a href="https://heineken-dark-market.com/ ">darknet dream market reddit </a> https://heinekendarkmarketplace.com/ - bitcoin market on darknet tor
名前
TimmyMeexy
how big is the darknet market <a href="https://heineken-onion-darkweb.com/ ">bohemia market darknet </a> https://heinekendarknetdrugstore.com/ - dxm pills
名前
RichardDek
dark web step by step <a href="https://kingdom-onion-darkmarket.com/ ">deep dark web markets links </a> https://kingdom-onion-darkmarket.com/ - decentralized darknet market
名前
DamonLat
dark web market list <a href="https://heinekenmarket-darknet.com/ ">deep deep web links </a> https://heineken-markett.com/ - dark web markets 2023
名前
JamesseM
versus project market url <a href="https://kingdom-darkmarket-online.com/ ">dark markets spain </a> https://kingdom-darkmarket-online.com/ - darknet guide
名前
CharlesNuh
best mdma vendor darknet market reddit <a href="https://kingdom-online-drugs.com/ ">drugs sold on dark web </a> https://kingdomonionmarket.com/ - how to access the black market
名前
Ronaldevica
best darknet market now <a href="https://kingdomdarkmarketplace.com/ ">shop ccs carding </a> https://kingdomdarkmarketplace.com/ - darknet markets reddit 2023
名前
Ralphzet
shop valid cvv <a href="https://heinekenoniondarkweb.com/ ">bitcoin market on darknet tor </a> https://heinekenoniondarkweb.com/ - darknet markets
名前
RobertKix
drugs darknet vendors <a href="https://kingdom-onion.com/ ">dark markets slovakia </a> https://darkwebkingdom.com/ - dark web live
名前
Danired

コメントを追加

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