Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Link to external file in CHM from Button1

Explorer ,
Sep 30, 2019 Sep 30, 2019

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-...

 

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. 

 

RH CHM link.pngexpand image

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

 

thanks.

TOPICS
Scripting
511
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2019 Sep 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 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 30, 2019 Sep 30, 2019

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

 

Script.pngexpand image

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2019 Sep 30, 2019
LATEST
I was thinking you would just modify the page you were using that had the clickable link that worked.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 30, 2019 Sep 30, 2019
Rick, sorry, did not work.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
RoboHelp Documentation
Download Adobe RoboHelp