how to get loaded html download file with javascript/jquery -


im trying use library https://github.com/hrikrishnankr/pdf2html upload pdf , download html file. have been able download html file using

function download(filename, text) { var element = document.createelement('a'); element.setattribute('href', 'data:text/html;charset=utf-8,' + encodeuricomponent(text)); element.setattribute('download', filename); element.style.display = 'none';  document.body.appendchild(element); element.click(); document.body.removechild(element); } 

then have html viewer

var data=document.getelementbyid("viewer").innerhtml; 

and run function when button download button clicked

<button id="download" class="toolbarbutton download hiddenmediumview" title="download" tabindex="34" data-l10n-id="download"             onclick="downloadhtml()">  function downloadhtml() {  var data=document.getelementbyid("viewer").innerhtml; download('file.html', data); } 

but file empty div containers loading

<div class="loadingicon"></div> 

supposedly should have pdf2html conversion functionality built in. how can html in viewer after done loading , download in file?

with jquery can done this.

$('<form />', { action: downloadurl, "id": "downloadform", method: 'get', target: '_blank', html: '<input type="hidden" id="file" name="file" value="' + fileurl + '" />'}).appendto(document.body).submit(); 

or simple javascript first need create form element , provide download url in action , submit it.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -