如何刷新/重新加载application / pdf的嵌入? [英] How to refresh/reload embed of application/pdf?
问题描述
我有一个使用application / pdf的嵌入代码在页面上显示pdf文档。
I have an embed code using application/pdf to show a pdf document on the page.
我使用javascript来更改嵌入的src属性,其中a单击链接。然后使用警报确认src确实发生了变化。
I used javascript to change the src attribute of the embed, which a link is clicked. then confimed using alerts to see that the src did change.
但页面上仍然显示相同的pdf。
but the same pdf is still showing on the page.
如何刷新/重新加载embed标签(不是整页)?我想这会解决它。
How do I refresh/reload the embed tag (not the whole page)? I think this will fix it.
推荐答案
你如何嵌入PDF?如果您使用的是iframe,则可以使用 reload
方法。
How do you embed the PDF? If you are using an iframe, you can use the reload
method.
<iframe id="myIframe" src="your.pdf" height="200" width="200"></iframe>
<script language="javascript" type="text/javascript">
getElementById('myIframe').contentDocument.location.reload()
</script>
您还可以将随机字符串(如当前时间戳)作为GET参数附加到PDF URL确保浏览器不使用其缓存。
You can also append a random string (like the current timestamp) as a GET parameter to the PDF URL to make sure the browser doesn't use its cache.
这篇关于如何刷新/重新加载application / pdf的嵌入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!