3

This simple code in a single cell works in Jupyter Notebook, but Deepnote seems to render the display_javascript calls into separate iframes. Is there any way to get this work in Deepnote?

from IPython.display import display_javascript

display_javascript("var a = 10", raw=True)
display_javascript("console.log(a)", raw=True)

Uncaught (in promise) ReferenceError: a is not defined

Example: https://deepnote.com/project/How-to-access-Javascript-variable-from-separate-displayjavascript-call-hvyWPhDWRGahj9NvgJtuGw/%2Fnotebook.ipynb

Background: I'm working on a JS charting library Jupyter integration (ipyvizzu), where I would like to access the JS chart object eventually from different cells in the notebook.

simon
  • 1,210
  • 12
  • 26
  • try `a=10` because it might be a scope issue that you're facing with `display_javascript` – The Bomb Squad Apr 01 '22 at 22:59
  • Same result with `a=10` or `window.a=10`. – simon Apr 01 '22 at 23:02
  • `window.a=10` would still refer to the window instance of each individual iframe; if anything, you'd need to go up a level, so that you are working with the window of the document that contains those iframes - `parent.a` – CBroe May 11 '23 at 09:12
  • Good idea, unfortunately, I got the following error then: Blocked a frame with origin "https://deepnoteworkspace.com" from accessing a cross-origin frame. – simon May 13 '23 at 08:57

0 Answers0