Download Button Not doing anything in IE and firefox for excel file

问题内容:

I have created a download button , which will download a .xlsx file.
The same is working perfectly in chrome , but not doing anything in IE and Firefox. I donot able to understand the exact problem here .

        <nav class="navbar navbar-inverse visible-xs">
        <div class="container-fluid">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>                        
              </button>

          <div><br/><br/><br/></div><br/>
    <div align="center">
      <div class="panel panel-default">
      <div class="panel-heading">
        <h3><?php echo $dirname; ?> Cities Charts <?php echo $project; ?></h3><button class="col-sm-offset-11 btn btn-success"><a href="/NT_Dashboard_withDB/Dashboard_Additional_Information.xlsx" download>Download Data</a></button></div></br></br>
        <div id="bodyContent" class="panel-body"></div></br></br>
        </div>
    </div>

问题评论:

    
which version of IE and firefox u on?
    
Try to update your other browsers
1  
The download attribute isn’t supported by all browsers.

答案:

答案1:

according to HTML syntax button cannot have <a> tag inside of it.

to solve your problem you can use <a > outside button or use javascript

<a href="/NT_Dashboard_withDB/Dashboard_Additional_Information.xlsx" download>Download Data<button class="col-sm-offset-11 btn btn-success"></button></a>

javascript:

<button class="col-sm-offset-11 btn btn-success" onClick="javascript:window.location='/NT_Dashboard_withDB/Dashboard_Additional_Information.xlsx'></button>

答案评论:

答案2:

The problem is support for the HTML5 download attribute. IE doesn’t support it and older versions of Firefox may not support it either.

https://caniuse.com/#search=download

答案评论:

    
who said op is using older version of the two?
    
The OP did, @MasivuyeCokile.
    
I have created a download button , which will download a .xlsx file. The same is working perfectly in chrome , but not doing anything in IE and Firefox. where exactly?

答案3:

Instead of using “button” tag to wrap “a” tag you can style tag as shown below.

<div class="panel-heading">
<h3><?php echo $dirname; ?> Cities Charts <?php echo $project; ?></h3>
  <a href="/NT_Dashboard_withDB/Dashboard_Additional_Information.xlsx" class="col-sm-offset-11 btn btn-success" download>Download Data</a>
</div>

This will work for you.

答案评论:

    
thank you very much… it worked
– Shubhajit Chanda
49 mins ago

原文地址:

https://stackoverflow.com/questions/47755432/download-button-not-doing-anything-in-ie-and-firefox-for-excel-file

Tags:

Add a Comment