Adobe RoboHelp: Get the Context Sensitive URL of a Topic
When coding buttons and other links, you may want to retrieve the context sensitive URL to a topic. This is useful for sharing a direct link to the topic.
The following function will return the context sensitive URL of a specific topic. If the skin is shown, the function will return a URL that will show the skin. When the skin is not shown, the function will return the full URL of the topic.
This script works for WebHelp and Browser Based AIR help.
function CSHURL() { var MasterUrl = top.location.toString(); if(top.frames[0]) { if (top.frames[0].name == "ContentFrame") { MasterUrl = top.frames[0].location.toString(); } if(MasterUrl.match("#")) { MasterUrl = MasterUrl.substring(0,MasterUrl.indexOf("#")); } var topicUrl = document.location.toString(); var RelPath = _getRelativePath(MasterUrl, topicUrl).substring(_getRelativePath(topicUrl, MasterUrl).length); var TopicName = topicUrl.substring(topicUrl.lastIndexOf("/") + 1); var url = MasterUrl+"#"+RelPath+TopicName; } else { var url = document.location.toString(); } return url; }