I have an application in which user can do some actions with ajax calls. When ajax call is done then the results of the action is append into my div with id = "log"
. I want to make a user option (button - Export) when he is done with his work that he can export his "activity log" into .txt file. So far i have succeed doing that but html converts into txt file with tags etc. I would like to remove tags and format a bit that .txt file but don't know how.
My HTML code is
<input type="button" value="Export" onclick="exportLog();">
<div id="log">
<p>Action 1 successful</p>
<p>Action 2 unsuccessful </p>
<p>Action 4 - contact admin</p>
<p>...etc</p>
</div>
Javascript code is
function exportLog(){
var elHtml = document.getElementById('log').innerHTML;
var link = document.createElement('a');
var mimeType = 'text/plain';
link.setAttribute('download', 'logFile');
link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml));
link.click();
}
I did this with a help of this. It works but my .txt file is like
<p>Action 1 successful</p><p>Action 2 unsuccessful </p><p>Action 4 - contact admin</p><p>...etc</p>
and i would like to look like
Action 1 successful
Action 2 unsuccessful
Action 4 - contact admin
...etc
How to achieve this?
will be?
– Sergii Shvager Jan 14 '16 at 09:15tags allowed
– KuKeC Jan 14 '16 at 09:19