I don't have much experience with JavaScript, but I found the following code in a .htm file. The function doesn't seem to be triggering when it should; It is supposed to activate when the page is directly opened i.e
www.site.com/12345.htm
This will change the URL to
site.com/#12345.htm
and load the necessary scripts and stylesheets.
The function shouldn't be triggered when accessed indirectly. For example, going to www.site.com/ shouldn't trigger it as the index.htm already loads the css/script instantly.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> Introduction </title>
<script type="text/javascript">
function isTOCLoaded() {
//this function loads the specific topic within the application if accessed independently
//for example, opening the topic .htm file or through search engine links
var url = window.location.href;
var baseUrl = url.substring(0, url.lastIndexOf("/") + 1);
var topicFile = url.substring(url.lastIndexOf("/") + 1)
var newUrl = baseUrl + "#" + topicFile;
location.href = newUrl;
return false;
}
</script>
</head>
<body>
<h1 id="t57117" class="heading1">Introduction</h1>
<input id="topicId" type="hidden" value="57117" />
<input id="topicDescription" type="hidden" value="Introduction" />
<input id="footer-modified" type="hidden" value="Last modified: 17/12/2015 8:18:59 a.m." />
</body>
</html>