Skip to main content
Inspiring
September 30, 2019
Question

Link to external file in CHM from Button1

  • September 30, 2019
  • 1 reply
  • 566 views

Hi All,

 

I've done some searching and have the start of this. Per Subject, I would like to link to a provided index.htm file that is included in the release CHM directory.  I searched the forum and found the following:

 

describes the JS to get the relative URL

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/htmlhelp/example--link-to-a-file-outside-of-your-help-system?redirectedfrom=MSDN

 

So here is what I tried.  I created a script in the RH2019.Patch9 project.

function

 

 

URL_Parser(fn) {
var X, Y, sl, a, ra, link;
ra = /:/;
a = location.href.search(ra);
if (a == 2)
X = 14;
else
X = 7;
sl = "\\";
Y = location.href.lastIndexOf(sl) + 1;
link = 'file:///' + location.href.substring(X, Y) + fn;
location.href = link;
}

 

 

Then I simply added a Button1 URL as follows:

 

 

<a onclick="URL_Parser('index.htm')" style="text-decoration: underline; color: green; cursor: hand">Link to QSG</a>

 

 

However, this does not work.

 

Searching a bit, someone recommended keeping the script right inside the HTM page. 

 

So I did a test link by adding the following to the bottom of my file:

 

 

<script language="JScript">
//<![CDATA[
function URL_Parser(fn) {
var X, Y, sl, a, ra, link;
ra = /:/;
a = location.href.search(ra);
if (a == 2)
X = 14;
else
X = 7;
sl = "\\";
Y = location.href.lastIndexOf(sl) + 1;
link = 'file:///' + location.href.substring(X, Y) + fn;
location.href = link;
}
//]]>
</script>
<p><a onclick="URL_Parser(&#39;index.htm&#39;)" style="text-decoration: underline;color:green;cursor: hand">Link to QSG</a></p>

 

 

And this worked per the figure. 

 

So what do I need to do to get this to kick off from the button?

 

thanks.

This topic has been closed for replies.

1 reply

Captiv8r
Brainiac
September 30, 2019

Hi there

I'm wondering if the answer here will be to simply configure the CHM Button 1 to display that page where you have the button. Then configure that page with an OnLoad statement that does the same thing that button press does. 

 

I'm thinking it might look something like this in the HTML:

<body onLoad="URL_Parser(&#39;index.htm&#39;)">

 

If this works, the user would click the button in the CHM toolbar, the page would load into the CHM window, the OnLoad statement would trigger and cause the external page to load outside the CHM. A bit of a set of dominos!

 

Cheers... Rick 🙂

Inspiring
September 30, 2019

OK thanks will try. Before I do, do I place the script in the script folder like this?

 

 

Note my script name in RH is SC_URL_Parser. Does it need to be the same as the function name?

Captiv8r
Brainiac
September 30, 2019
I was thinking you would just modify the page you were using that had the clickable link that worked.