How to link a PDF file in CHM files?

Here is a piece of code for opening a PDF file directly inside a CHM file provided by Sjoerd B. Franken.

Include this script in the HEAD tag
<SCRIPT Language="JScript">
function parser(fn)
var X, Y, sl, a, ra, link;
ra = /:/;
a =;
if (a == 2)
X = 14;
X = 7;
sl = "\\";
Y = location.href.lastIndexOf(sl) + 1;
link = 'file:///' + location.href.substring(X, Y) + fn;
location.href = link;

Then link this way
<a onclick="parser('Your_PDF_File.pdf')" style="text-decoration: underline;
color: green; cursor: hand">Click ME Please!</a>

The PDF file must be distributed together with the CHM file and they must be in the same directory.

Return to topReturn to top