# Friday, 17 March 2006

Sometimes being automatically offered the choice to download or open a .pdf is desired.  There are different methods to do this, using Active X, Java, JavaScript and ASP coding.  Here are several different ways to publish pdf files on IIS, some of which giving an open/save choice without and scripting.

Method1 - Embed

Use: <EMBED src="/path/to/file" width="600" height="600" type=application/pdf href="/path/to/file"></EMBED> <NOEMBED>Your browser does not support embedded PDF files.</NOEMBED>

note: works in IE6, Firefox 1.5; add "href=" for netscape

Your browser does not support embedded PDF files. <A href="http://blog.johnkelly.co.uk/content/binary/13predictions.pdf">Open file by clicking here.</A>


Method2 -

13predictions.pdf (62.89 KB)


Method3 -

download


Method4 -

download-2


Method5 - Object

<OBJECT CLASSID="clsid:CA8A9780-280D-11CF-A24D-444553540000" WIDTH="600" HEIGHT="600">
        <PARAM NAME="SRC" VALUE="path/to/file">
        <PARAM NAME="HREF" VALUE="path/to/file">
        <EMBED SRC="path/to/file" HEIGHT="500" WIDTH="500" HREF="path/to/file">
                <NOEMBED>
                        Your browser does not support embedded PDF files.
                </NOEMBED>
        </EMBED>
</OBJECT>

Note:  Due to a bug in FreeTextBox (DasBlog's native editor) this approach works, briefly, until the post is edited which screws up the EMBED code.

 


Method6 - iframe

 


Method7 - ftp

A link to the file via an ftp site might open the file in the same window, a new window or offer an open/save dialog depending on the browser

 

html | ie | pdf
Friday, 17 March 2006 11:25:28 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |  Trackback
# Sunday, 05 February 2006

To have certain links opening in a new window (and to be HTML 4.0 & XHTML 1.0 Strict compliant) use the following procedure:

1.   Create text file "external.js" containing:

function externalLinks() { 
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

and save this in a new directory "\scripts"

2.   Edit header secion of "homeTemplate.blogtemplate" to contain:

<script type="text/javascript" src="scripts/external.js"></script>

3.    Using dasBlog's native editor (in HTML section) edit links to be in the following format:

<a href="document.html" rel="external">external link text</a>

For example:

BBC News site in new window

 

Update Regardless of tab settings, in Firefox links always seem to want to open in the same tab. The only way to force them to open in a new tab is to include the javascript in the document rather than a link to an external .js file.
Sunday, 05 February 2006 13:45:18 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |  Trackback