Problem
If you see the left side panel under "Frameworks and Extensions" section, it says that "No-Library (pure JS)" is used and script will be activated on "onLoad". This thing is automatically handled by jsfiddle website.
But if you run the page in browser and see the console of developer tool, it will point out the below issue...
TypeError: create is null
create.addEventListener('click', function () {
Solution
So, we just need to call the script on window onload like.
window.onload = function(){
var textFile = null,
makeTextFile = function (text) {
var data = new Blob([text], {type: 'text/plain'});
if (textFile !== null) {
window.URL.revokeObjectURL(textFile);
}
textFile = window.URL.createObjectURL(data);
return textFile;
};
var create = document.getElementById('create'),
textbox = document.getElementById('textbox');
create.addEventListener('click', function () {
var link = document.getElementById('downloadlink');
link.href = makeTextFile(textbox.value);
link.style.display = 'block';
}, false);
};
Demo
[Demo] Generate File in JavaScript[
^]