0

I tried to use embed and iframe tags which work for the first page.

<iframe src="~/Documents/Upload/myPDF.pdf" id="pdfDisplay"> 

But when I try to change the src in javascript, I get the same page displayed over again.

document.getElementById('pdfDisplay').setAttribute("src", "~/Documents/TextDetection/Upload/" + files[currentIndex]);

Where files[currentIndex] is the dynamically generated filename that exists in the local storage.

I don't know what I am doing wrong because its not working.

  • 2
    sure you don't have a closure problem? currentindex is set to the last value in your loop? https://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example – Bryan Dellinger Mar 29 '21 at 01:31
  • I printed the file names to check, and they do change. So don't think its a closure problem. – shashwat arya Mar 29 '21 at 02:54

0 Answers0