Embedded Notebooks - redefine

Hi folks,

I’ve been hosting a notebook using Javascript on my site and I’ve been using a select box to change the language using.

import {Runtime, Inspector} from “https://cdn.jsdelivr.net/npm/@observablehq/runtime@5/dist/runtime.js”;
import define from “https://api.observablehq.com/@bmdatavisualisation/apt.js?v=4”;
const notebook = new Runtime().module(define, name => {
if (name === “finalChart”) return new Inspector(document.querySelector(“#observablehq-finalChart-92d14b0e”));
});

notebook.redefine(“language”, “pt”)

It’s being hosted on another site within an iframe (I don’t have access) and I had the smart idea that if they set up a message then I could detect when the url changes so that I could dynamically change the language.

It doesn’t seem to be working - I’m guessing something to do with state/runtime/the fact that it’s hosted on another site within a iframe and might not even be possible to do but thought I’d ask…

Many thanks,

Bryony

What have you tried specifically to access the language? And is the iframe sandboxed or served from a different origin than its parent page?

Thank you @mootari. I set up a page on my website as an example of how a notebook could be hosted and they ended up embedding the whole page.

I found a solution though - I’m detecting the language from the url search string which they are now changing within the iFrame if the user switches language.. Thank you for reaching out.

1 Like