Copy link to clipboard
Copied
We have RoboHelp 2017 (latest version). We use a merged HTML5 help system, and we're customizing our first page (intro.htm) in that merged help system
I'm knee-deep in Javascript code, and I need my js code on that page to find out if we're in a full context view or not. The easiest way, I can think of is to just check the URL.
Example URL (Not in Full Context):
file:///D:/DocProjects/Outputs/pcdmis/2021.1/en/helpcenter/mergedProjects/helpcentertopics/intro.htm
Example URL - In Full Context):
file:///D:/DocProjects/Outputs/pcdmis/2021.1/en/helpcenter/index.htm#t=mergedProjects%2Fhelpcentertopics%2Fintro.htm
Note that the full context view has "#t=". That's the magic bit I'm checking for. Also, note that intro.htm is within a child project in the merged help system, and the javascript script is called within that project.
I pass the URL into this function which checks if the URL has "#t=" so that the function can determine if I'm in full context view or not:
function isFullContext(url){
console.log(url + " - made it into isFullContext function")
if (url.indexOf("#t=") > -1) {
console.log(url + " - full context is true");
i = true;
} else {
console.log(url + " - full context is false");
i = false;
}
return i;
}
The problem is that the code never returns the full URL (the one with the "#t=") even though I can visually see the full-context URL in my browser address bar.
I've tried these:
window.location.href
document.location.href
Even though I'm clearly in a full-context view, with the longer URL, the above attempts always return this string/URL:
"file:///D:/DocProjects/Outputs/pcdmis/2021.1/en/helpcenter/mergedProjects/helpcentertopics/intro.htm"
Apparently, my page in the "frame"--or whatever you call it that RH puts around the page in full-context view--has no concept that the frame exists.
Is there a function that that returns the full text of the address field in the browser that I'm missing? Am I putting my script in the wrong spot? Should it be in the parent project? Or, is there a RoboHelp function that RH uses to know if it's in full context view that I could use?
I found a function (thingy?) called isIframe(). Manually adding this to an output topic at least logs a console note.
<script>
if(iFrm = rh._.isIframe()) {
console.log("Framed!");
} else {
console.log("Not framed");
}
</script>
I found it after some internet searching turned up this:
https://humanwhocodes.com/blog/2013/04/16/getting-the-url-of-an-iframes-parent/
Copy link to clipboard
Copied
I found a function (thingy?) called isIframe(). Manually adding this to an output topic at least logs a console note.
<script>
if(iFrm = rh._.isIframe()) {
console.log("Framed!");
} else {
console.log("Not framed");
}
</script>
I found it after some internet searching turned up this:
https://humanwhocodes.com/blog/2013/04/16/getting-the-url-of-an-iframes-parent/
Copy link to clipboard
Copied
In a word, that my friend, Amebr, was amazing! I spent six hours the last couple of days trying to figure this thing out and thought it might be impossible as I ended up getting cross origin issues trying to do parent.location to get the parent iframe url yesterday.
This is exactly what I needed! And it's simpler too than my approach. Less code. Thank you so much!