Run an external JS function


I am trying to run a JS function that is imported into Hype, I have searched the forum and although there are some examples I could not replicate for my particular scenario.

Any help is really appreciated. (25.9 KB)


The problem is that the element with your code is in an HTML Widget, which is an <iframe> element under-the-hood. This means that your OtherFunctions.js is not technically within that document. To fix:

  1. Create a Rectangle element (this is just a <div> on the same page)
  2. Remove all border/background styling so it appears as blank
  3. Choose Edit > Edit Element’s Inner HTML and then paste your code there

As a side note, I see you are importing jquery, but looking at the Head HTML this is getting imported after your OtherFunctions.js. If you intend to use it in OtherFunctions.js, then you will need to change the ordering. To do so, copy and paste the script tag for the file below the jquery line. Then uncheck the “Include in document <head>” box in the Resources Library so it doesn’t appear above.

Thanks Johnathan.

I now understand how to add a JS and access the script. Also, thanks for the point about the script order.


1 Like