Page 1 of 1

WebHelp redirection and fragment in URL

Posted: Wed Jun 08, 2016 6:28 pm
by HomeGoods
Hi,

Are there any ways to suppress the redirection in WebHelp?

For example, open this URL: https://www.oxygenxml.com/doc/versions/ ... r1m_kfs_zp

Case 1: If JavaScript is disabled on the client web browser, the pages is opened and scrolled to the middle of the page where "#edit-topics__ul_r1m_kfs_zp" is assigned.
Case 2: If JavaScript is enabled on the client (as usual), you are redirect to another URL. This time, the page is not scrolled. The original fragment "#edit-topics__ul_r1m_kfs_zp" is lost.

Sometimes I need the behavior of Case 1 even when JavaScript is enabled, particularly when I have to ask someone to look at a specific portion of the page.
If I could give a certain URL (something like .../eppo-edit-topics.html?redirect=no#edit-topics__ul_r1m_kfs_zp) and if it behaved in the way of Case 1, it would help very much.

Re: WebHelp redirection and fragment in URL

Posted: Wed Jun 08, 2016 6:33 pm
by HomeGoods
Another more specific use case is WebHelp with Feedback.
Its notification email contains a URL like .../foo.html#10 - but it doesn't work.

Re: WebHelp redirection and fragment in URL

Posted: Thu Jun 09, 2016 3:16 pm
by bogdan_cercelaru
Hello,
HomeGoods wrote:Are there any ways to suppress the redirection in WebHelp?
If you want to completely disable the redirect, then you should edit the [DITA_OT_DIR]/plugins/com.oxygenxml.webhelp/oxygen-webhelp/resources/js/webhelp_topic.js file and remove or comment the following line:

Code: Select all

window.location.href=getPath(location.pathname);
HomeGoods wrote:Case 2: If JavaScript is enabled on the client (as usual), you are redirect to another URL. This time, the page is not scrolled. The original fragment "#edit-topics__ul_r1m_kfs_zp" is lost.
This shouldn't happen. To resolve this, you should edit the [DITA_OT_DIR]/plugins/com.oxygenxml.webhelp/oxygen-webhelp/resources/skins/desktop/toc_driver.js and change the following line

Code: Select all

newLink = newLink + "#" + location.search.substring(pos + wh.directory.length)
with:

Code: Select all

newLink = newLink + "#" + location.search.substring(pos + wh.directory.length) + location.hash;
Regards,
Bogdan

Re: WebHelp redirection and fragment in URL

Posted: Thu Jun 09, 2016 6:28 pm
by HomeGoods
bogdan_cercelaru wrote:

Code: Select all

newLink = newLink + "#" + location.search.substring(pos + wh.directory.length) + location.hash;
Thanks for the fix.
For me to get it work, two more changes were necessary.
  1. [DITA_OT_DIR]/plugins/com.oxygenxml.webhelp/oxygen-webhelp/resources/js/webhelp_topic.js
    Replace

    Code: Select all

    window.location.href=getPath(location.pathname);
    with

    Code: Select all

    window.location.href=getPath(location.pathname) + location.hash;
    because without it, toc_driver.js didn't receive the fragment in the first place.
  2. [DITA_OT_DIR]/plugins/com.oxygenxml.webhelp/oxygen-webhelp/resources/skins/desktop/toc_driver.js
    Replace

    Code: Select all

    newLink = newLink + "#" + location.search.substring(pos + wh.directory.length -1);
    with

    Code: Select all

    newLink = newLink + "#" + location.search.substring(pos + wh.directory.length -1) + location.hash;
    because I'm testing locally.