-1

I am facing a roblem where html page anchor href set in html opens a pdf in the same window BUT when href is set in javascript it just downloads the document. I need to open the dynamically-set doc in current browser window. Page uses java query 1 7 1 js. The href is tried and true.

forcing target="_self" does not help, it is default anyways any function of onclick applied to the anchor tag fires but is ignored. tried regular js as well as jquery happens in IE, Safari, Chrome, did not try others but not interested for now

I am open to try any suggestions.

not moodyfying the above to be honest in respect to the kind person who answered first.

here is what I found thanks to the answer: It doesn't matter if the link is set dynamically, nothing wrong with the pdf document, problem seems to be the location of the doc. When I reference that doc in one domain it opens in current browser just fine, only the new domain location creates this problem ( I copied the old document there ).

4

1 回答 1

0

我需要在当前浏览器窗口中打开动态设置的文档。

在浏览器中打开 PDF 是一个依赖于浏览器的功能。默认情况下,Google Chrome 会执行此操作,而 Firefox 需要安装 Adob​​e Reader。

强制 target="_self" 没有帮助,无论如何它都是默认的,任何应用于锚标记的 onclick 功能都会触发但被忽略。

如果您不提供任何内容,默认情况下,浏览器会在同一窗口中打开。如果它下载,请检查响应标头Content-disposition: attachment;并使用支持打开 PDF 的浏览器进行检查。

于 2012-09-28T07:47:07.333 回答