Skip to main content
Known Participant
February 18, 2022
Question

Run javascript when topic loads

  • February 18, 2022
  • 6 replies
  • 1359 views

I'm having issues when trying to run javascript on topic pages. I have a script that makes videos responsive but the code will only run once on page load. When navigating between topic pages the code does not run since theres no page load between these.

I've tried inserting the code in the masterpage but still the code won't execute when clikcing between topics. Any ideas?

    This topic has been closed for replies.

    6 replies

    Inspiring
    July 7, 2023

    We are experiencing a similar issue.

    I believe this problem is caused by the React engine, which only loads once when the page is initially loaded. When switching between topics, the React app doesn't re-run, resulting in no changes being applied to the other topics.

    Within our project, we have two JavaScript scripts. One is responsible for highlighting, while the other looks for specific words and changes the text color accordingly. However, neither of these scripts is functioning unless you reload the page or use a direct link to the desired topic.

    Jeff_Coatsworth
    Community Expert
    Community Expert
    July 7, 2023

    @defaultv667u7s1tnd8 if you are using Frameless too, I'd jump on that Tracker bug report & cast your vote.

    Inspiring
    July 7, 2023
    Community Expert
    January 16, 2023

    It would be worth logging a bug report, I think. It seems like most development is being done in the Frameless skins, rather than Responsive, and they do offer more customisation options. You can request features and report issues here: https://tracker.adobe.com/

    Post the item number in the discussion so people can easily vote if they want the same functionality.

    davidk99046111
    Inspiring
    June 15, 2023

    I am not sure if he created the bug but I went ahead and did so as I am facing the same issue.  This is not on a SharePoint deployment.  I have a chat widget for one page, and a highlight script applied to all pages.  Nothing I have tried can get the scripts to fire upon initial load when navigating from the frameless toc.  Only after i refresh the page does it load.  
    Ticket Link - https://tracker.adobe.com/#/view/RH-11720

    Participating Frequently
    January 9, 2023

    Hello a_David,

     

    I believe I have a similar issue. The javascript does not run unless the page is refreshed. Were you able to resolve this issue? If so, what was the resolution?

    This is the link to my post: It includes a description as well as short video of the issue. It seems similar to yours.  JavaScript files only load upon refresh in SharePo... - Adobe Support Community - 13470453

     

    Looking forward,


    Ken

    a_DavidAuthor
    Known Participant
    January 12, 2023

    Hi Ken,

    No, I've not been able to resolve this unfortunately. 

    Participating Frequently
    January 16, 2023

    So I think my issue is resolved. I switched my skin from Frameless to HTML5 and it seems to work. I am going to do a bit more testing, but I believe that was the trick for me. 

    Community Expert
    February 22, 2022

    I think you'll have to contact support on this one. Use the email address on this page as it goes to Robohelp support staff.https://helpx.adobe.com/contact/enterprise-support.other.html#robohelp

    Community Expert
    February 21, 2022

    If you added the script to only a single topic, then it will only run when you navigate to that topic.

     

    I created a test project with Topic A and Topic B. I added the script in Topic A, but just above the closing body tag, because I don't think it would work at all after the html tag.

     

    As expected, the script runs when I navigate to Topic A. Also as expected, when I navigate to Topic B, the script doesn't run because it isn't in Topic B. When I navigate back to Topic A, the script runs.

     

    If you want the script in multiple topics, I would recommend including the script in a master page. You can then either assign the master page to each topic you want the script in, or assign it in your output preset and the script will be included in all topics.

    a_DavidAuthor
    Known Participant
    February 22, 2022

    Yes of course, the script would only be run on the specific topic. Either way, it doesn't matter where the script is added, in the masterpage or specific topic, the script will only run when the page is loading which would be once, not when navigating between topics.

    Please take a look att my recording of the behavior below.
    https://www.screencast.com/t/53EvAWy0b 

    Community Expert
    February 20, 2022

    Which version of Robohelp are you using? If 2019, include whether you're using Classic or New UI. Also, which output and skin are you generating?

    a_DavidAuthor
    Known Participant
    February 21, 2022

    So sorry... I'm using 2020.7.46 with the skin "Orange" as base.