CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2022-09-20
by Archit Gargi

Original Post

Original - Posted on 2013-08-12
by Matěj Pokorný



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You can use the following code to download a HTML file -
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
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); }
<!-- end snippet -->
Simple solution for HTML5 ready browsers...
<!-- begin snippet: js hide: false -->
<!-- language: lang-js -->
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); }
<!-- language: lang-css -->
form * { display: block; margin: 10px; }
<!-- language: lang-html -->
<form onsubmit="download(this['name'].value, this['text'].value)"> <input type="text" name="name" value="test.txt"> <textarea name="text"></textarea> <input type="submit" value="Download"> </form>
<!-- end snippet -->
**Usage**
download('test.txt', 'Hello world!');

        
Present in both answers; Present only in the new answer; Present only in the old answer;