Note that there are some explanatory texts on larger screens.

plurals
  1. PODownloading files using html5 blobs in a chrome-extension
    primarykey
    data
    text
    <p>Im trying to achieve the same goal as OP there: <a href="https://stackoverflow.com/questions/6165266/downloading-mp3-files-using-html5-blobs-in-a-chrome-extension/11518906#11518906">Downloading mp3 files using html5 blobs in a chrome-extension</a> but not the him's code, not the solution offered in discussion does not work for my google-chrome 19.0.1084.46. Im working in chrome-console on the local (file://) page, and errors for this code:</p> <pre><code>finalUrl = "http://cs1076.userapi.com/u3040678/audio/d7ff6874cfa4.mp3"; var xhr = new XMLHttpRequest(); xhr.open("GET", finalURL, true); xhr.setRequestHeader('Content-Type', 'octet-stream'); xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); xhr.onreadystatechange = function() { if(xhr.readyState == 4 &amp;&amp; xhr.status == 200) { var bb = new (window.BlobBuilder || window.WebKitBlobBuilder)(); bb.append(xhr.responseText); var blob = bb.getBlob("application/octet-stream"); var saveas = document.createElement("iframe"); saveas.style.display = "none"; saveas.src = window.webkitURL.createObjectURL(blob); document.body.appendChild(saveas); delete xhr; delete blob; delete bb; } } xhr.send(); </code></pre> <p>looks like </p> <blockquote> <p>OPTIONS <a href="http://cs1076.userapi.com/u3040678/audio/d7ff6874cfa4.mp3" rel="nofollow noreferrer">http://cs1076.userapi.com/u3040678/audio/d7ff6874cfa4.mp3</a> 405 (Not Allowed) cs1076.userapi.com/u3040678/audio/d7ff6874cfa4.mp3:1 XMLHttpRequest cannot load <a href="http://cs1076.userapi.com/u3040678/audio/d7ff6874cfa4.mp3" rel="nofollow noreferrer">http://cs1076.userapi.com/u3040678/audio/d7ff6874cfa4.mp3</a>. Origin null is not allowed by Access-Control-Allow-Origin.</p> </blockquote> <p>And the second subquestion: in according to <a href="https://stackoverflow.com/questions/6175421/how-can-i-generate-a-file-and-offer-it-for-download-in-plain-javascript/11518859#11518859">How can i generate a file and offer it for download in plain javascript?</a> - is the creation of iframe the best way to offer file to download?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload