Javascript in version filter does not redirect on 404

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
Giri
Jr. Propeller Head
Posts: 3
Joined: Fri Apr 26, 2019 11:22 pm

Javascript in version filter does not redirect on 404

Post by Giri »

We have developed a HTML5 - TopNav product documentation site by using Madcap Flare 2018r2. Here is the site: https://support.asg.com/dhw/overview/ab ... rview.html. We use bit bucket repositories to commit all our projects from Flare.

Some of the products have product doc versions. In bit bucket, each product doc version is a separate repository. We have a common landing page (https://support.asg.com/WEB/home.htm), which is also in a bit bucket repository (an individual Flare project).

When users go to any doc site and read a topic, they have the option to switch to another product doc version. This is done from the version filter drop down at the top right. If a matching file is found in the other product doc version -- no issues. However, if a matching html file is not found in another documentation version, the JavaScript that loads the version filter should pop up an alert instead of the 404 page. This is the problem that I am trying to solve - instead of displaying the 404.htm, I need the .js file to provide users with options.

The "top level" Flare project (the one for the landing page) has a versionfilter.js that takes the reader to another topic in another doc version (if the user selects it from the drop down). The versions and parameters are defined in a config.json in the same Flare project.

In each of the product docs (for example https://support.asg.com/dhw) a snippet is defined that calls the config.json in the top level Flare project, which in turn reads the versionfilter.js.

This works fine ... try to select different pages and navigate between the versions (for example - https://support.asg.com/dhw/home.htm)

However, when a matching file is not found in the other version (for example https://support.asg.com/dhw/overview/ab ... rview.html) a 404 page is loaded.

I took the help of a developer and tried to add an Ajax call in the versionfilter.js to redirect when a page is not found. But this is not working.

We use IIS as the production server.

Is there someone who can help?

Here is the content of the snippet file (unable to attach it so pasting the contents here):
--------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd">
<head>
</head>
<body>
<div id="filterVersion"></div>
<script>
$(document).ready(function() {
new VersionFilter({project: "ws"});
});
</script>
</body>
</html>
--------------------------------------------------------------------------------------------------
The config.json file:

{
"ida": {
"versions": ["9_5", "9_2"],
"default": "9_5"
},
"idc": {
"versions": ["9_5", "9_2", "9_0"],
"default": "9_5"
},
"ws": {
"versions": ["10_2", "10_0"],
"default": "10_2"
}
}

---------------------------------------------------------------------------------------
versionFilter.js
In the attached versionfilter,js, I added this:

$.ajax(
{
type: "get",
url: url,
cache: false,
statusCode: {
404: function ()
{
alert('page not found');
},
200: function ()
{
window.location.href = url;
}
},
async: false
});


But I still get a "versionFilter not defined" in Chrome Developer tools > Error checker.

Thanks
Giri
You do not have the required permissions to view the files attached to this post.
amitkapoor
Propeller Head
Posts: 33
Joined: Mon Sep 16, 2019 5:23 am

Re: Javascript in version filter does not redirect on 404

Post by amitkapoor »

Hi Giri,

How did you solve the issue if you could share it with us?

-Amit
Post Reply