--------------------------------------- <!---http://fiddle.jshell.net/ourcodeworld/rce6nn3z/2//show--> <script type="text/javascript" src="/js/lib/dummy.js"></script> <link rel="stylesheet" type="text/css" href="/css/result-light.css"> <style id="compiled-css" type="text/css"> /* EOS */ </style> <script id="insert"></script> </head> <body> <textarea id="text-val" rows="4">Enter Text here</textarea><br/> <input type="button" id="dwn-btn" value="Download"/> <script type="text/javascript">//<![CDATA[ function download(filename, text) { var element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); element.setAttribute('download', filename); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); } // Start file download. document.getElementById("dwn-btn").addEventListener("click", function(){ // Generate download of hello.txt file with some content var text = document.getElementById("text-val").value; var filename = "hello.txt"; download(filename, text); }, false); //]]></script> <script> // tell the embed parent frame the height of the content if (window.parent && window.parent.parent){ window.parent.parent.postMessage(["resultsFrame", { height: document.body.getBoundingClientRect().height, slug: "rce6nn3z" }], "*") } // always overwrite window.name, in case users try to set it manually //window.name = "result" </script> </body> </html> </plaintext>