• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Run javascript when topic loads

Explorer ,
Feb 18, 2022 Feb 18, 2022

Copy link to clipboard

Copied

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?

Views

576

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2022 Feb 20, 2022

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 20, 2022 Feb 20, 2022

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 20, 2022 Feb 20, 2022

Copy link to clipboard

Copied

So I've tried adding a simple script in one of the topic like so:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="generator" content="Adobe RoboHelp 2020" />
  <title>Test</title>
</head>
<body>
  <h1>Test</h1>
</body>
</html>
<script type="text/javascript">
  console.log("hello");
</script>

Now the log script will fire when reloading the page but when going from another topic page to this the script won't fire.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

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 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

So in my video it shows that the log script only fires when I load the page, not when navigating to the topic. If it did it would be multiple of console logs in the console window.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

To be clear, the script fires correctly when I'm locally testing with the "view output", this is because the whole project is reloaded when navigating between topics locally. It's when the project is published and on a server that the scripts stops working becasue the whole site is only loaded once you first visit, when navigating topics there's no page load once on the server.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2022 Feb 22, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 09, 2023 Jan 09, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 11, 2023 Jan 11, 2023

Copy link to clipboard

Copied

Hi Ken,

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 16, 2023 Jan 16, 2023

Copy link to clipboard

Copied

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2023 Jan 16, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 15, 2023 Jun 15, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
RoboHelp Documentation
Download Adobe RoboHelp