I am using an <object>
tag to display document previews on my website.
Essentially, I pull out the document URL and type from my database, and give it to the <object>
tag as follows:
<object data="url" type="type" width="100%" height="100%">
<p>Fallback in case the browser couldn't display the document</p>
</object>
Every time the user selects a different document, I just replace the two parameters on the same <object>
tag (it's placed in a modal window).
Everything works fine, swapping documents works flawlessly, as long as the browser can render the documents (so, for example, moving from image/jpeg
to application/pdf
and back is fine).
However, as soon as one document cannot be rendered by the browser for any reason (e.g. the user doesn't have a PDF plugin), then all the following documents don't work either.
Is there any way I can reset the <object>
tag, to be able to start showing documents again, without refreshing the page?
Otherwise, do you have any other suggestions to implement a document viewer other than with an <object>
tag?
Thank you very much!