Copy link to clipboard
Copied
Hi
We have a large number of projects and want a script that, when run from a topic (the user clicks some link), picks up the project name, in the same way for example that it can pick up the topic title by using the Javascript 'document.title' .
Thanks,
Peter B
Hi,
To quickly get the project title, use top.document.title. This will only work if the entire skin is showing. When the skin is not showing, use show(); to open the skin.
Alternatively, the following (crude) function tries to retrieve the project title for you. It either returns the title or it returns false.
function GetProjectTitle() {
if(!isTopicOnly())
var Title = top.document.title;
else
{
if(gsStartPage.substr(0,4) == "file")
{
var Title = false;
}
else
{
Copy link to clipboard
Copied
Hi Peter
I'm thinking the only way you can accomplish this is by populating the HTML of each topic with a JavaScript variable containing the Project Name. Then you would be able to read that variable and use it later.
Unfortunately, I don't believe there is anything in RoboHelp that will really assist much with this. So likely it will mean visiting each topic to insert the variable. I suppose you might be able to accomplish it fairly easily using a Find and Replace tool.
Cheers... Rick
Helpful and Handy Links RoboHelp Wish Form/Bug Reporting Form Begin learning RoboHelp HTML 7 or 8 moments from now - $24.95! |
Copy link to clipboard
Copied
Hi,
To quickly get the project title, use top.document.title. This will only work if the entire skin is showing. When the skin is not showing, use show(); to open the skin.
Alternatively, the following (crude) function tries to retrieve the project title for you. It either returns the title or it returns false.
function GetProjectTitle() {
if(!isTopicOnly())
var Title = top.document.title;
else
{
if(gsStartPage.substr(0,4) == "file")
{
var Title = false;
}
else
{
try {
var sRelStartFile = _getRelativeFileName(document.location.href, gsStartPage);
try {
var oRequest = new XMLHttpRequest();
}
catch(e) {
var oRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
oRequest.open("GET",sRelStartFile,false);
oRequest.send(null)
var Content=oRequest.responseText;
//Quickly split the text into arrays to get the title. No bothering with DOM.
var beginTitle = /<title>/g;
var endTitle = /<\/title>/g;
var Title = Content.split(beginTitle);
var Title = Title[1].split(endTitle);
var Title = Title[0];
}
catch(e)
{
var Title = false;
}
}
}
return Title;
}
The function tries to get the content of the startpage from the server. This only works when your help is placed on a server. This function allways returns false when you call the help from a local disk.
Greet,
Willam
Copy link to clipboard
Copied
Neat and easy!
top.document.title gives me the project name and document.title gives the topic title.
Thanks,
Peter