Javascript reference error only in Canvas

hyim
Community Explorer

Hello everybody.  My javascript skills are a little rusty so I am hoping someone will take mercy on me and help me dubug this script.  We are trying to use a 3rd party script (see https://github.com/Sefaria/Sefaria-Project/wiki/Sefaria-Auto-Linker) to automatically add source links to textual references within our courses.

The script works beautifully on a simple test page https://looksteinvirtual.org/test.html but when I call it within canvas I get the following error "ReferenceError: Can't find variable: atomic" with a reference to line 214.

I am calling the script (which I am hosting on our own server to enable https and avoid mixed content errors) with the following code in our custom JS file:

var SefariaScript = document.createElement('script');

SefariaScript.setAttribute('charset', 'UTF-8');

SefariaScript.setAttribute('src', 'https://looksteinvirtual.org/Sefaria_linker.js');

SefariaScript.onload = function () {sefaria.link();};

document.body.appendChild(SefariaScript);

My first thought was that it was an issue of scope, but the same script (called the same way) works perfectly on non canvas sites. What am I missing??? Please help!

Thanks in advance,

Hyim

0 Likes