开发者

window.open(url) fails to download the pdf file

I am trying to open a URL, which points to a PDF, using window.open(url). In IE, the popup window flashes and nothing happens afterwords. When I access the same url directly using IE, PDF opens up perfectly. In the HTML below, when I click on Link, I get the PDF but window.open fails. Moreover, if I provide a direct link of PDF in window.open that also works perfectly. Could any body shed some light on this?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>

<BODY>
    <a href="http://phx.corporate-ir.net/External.File?item=UGFyZW50SUQ9NDk2Mjl8Q2hpbGRJRD0tMXxUeXBlPTM=&t=1">开发者_如何学JAVALink</a>
<script>
    url = "http://phx.corporate-ir.net/External.File?item=UGFyZW50SUQ9NDk2Mjl8Q2hpbGRJRD0tMXxUeXBlPTM=&t=1";        
    window.open(url);           
</script>
</BODY>
</HTML>

Thanks


Most browsers block window.open when is called without user interaction in order to avoid popup advertisements.

Why are doing this anyway? Instead you should link directly to the PDF in the original document, where you can use target="_blank" if it must be in a new window. (Keep in mind, that there are users that don't like it if websites open new windows).


This may just be my convention, but I always use window.open() like this:

var win = window.open(url);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜