在html5中下载链接

时间:2016-01-11 16:12:09

标签: html5 css3

我试着点击我的页面下载链接,在那里我可以下载pdf文件。我在下面使用此块,但是当我尝试下载文件时,它失败了。我该如何解决这个问题?

<div>
       <a href="http://www.mypage.com/documents" download="name_of_file.pdf" class=" btn btn-lg btn-outline">Download CV english version </a>
    </div>

1 个答案:

答案 0 :(得分:0)

L.mapbox.accessToken = 'pk.eyJ1IjoiemFrc2Nsb3NldCIsImEiOiJjaWY2dWxkc2gwcXBjczVtM3pnc3hydnI1In0.ABQHwIrVx95WhAVv_2JPeA'; var map = L.mapbox.map('map') .setView([40.71, -74.00], 11) .addLayer(L.mapbox.tileLayer('mapbox.dark')); function getColor(d) { return d > 30 ? "#0868ac" : d > 20 ? "#43a2ca" : d > 10 ? "#7bccc4" : d > 0 ? "#a8ddb5" : "grey"; }; //load poverty data var povertyData = "https://raw.githubusercontent.com/Kaz-A/Daycare-Facilities-/master/poverty.geojson"; $.getJSON(povertyData, function(povertyData) { //get unique poverty % values var povertyFeatures = povertyData.features; var uniquePoverty = []; povertyFeatures.forEach(function(x) { if (!povertyFeatures[x.properties.PopInPover]) { uniquePoverty.push(x.properties.PopInPover); povertyFeatures[x.properties.Poverty] = true; } }); console.log(povertyData); console.log(uniquePoverty); //styling the choropleth function style(feature) { return { fillColor: getColor(feature.properties.PopInPover), weight: 1, opacity: 0.3, color: "#000", dashArray: "1", fillOpacity: 0.3 }; }; //add poverty data var addPovertyData = L.geoJson(povertyData, { style: style }); //checkbox event to overlay poverty data $(".checkbox-primary").click(function() { if (this.checked) { console.log("checked!"); addPovertyData.addTo(map); } else { console.log("unchecked!"); addPovertyData.clearLayers(); }; }); });是一个文件夹,而不是文件。尝试将http://www.mypage.com/documents更改为文件

示例:

href

您可以使用<div> <a href="http://www.mypage.com/documents/your_specific_file.jpg" class=" btn btn-lg btn-outline">Download CV english version </a> </div> 属性更改文件的名称。例如,如果您添加download,则该文件将以download="New_name.jpg"而不是New_name.jpg下载