2

I have one html file (file.html) which contains a javascript function as below :

file.html

<html>
 <head> 
 </head>
<script>
    function demo()
    {
       do something using param1;
    }
</script>
</html>

'Param1' is the array that I need to pass from an IPython notebook everytime I call this file.html. The requirement is to show the the output of file.html in the notebook itself which I am doing using the following commands.

from IPython.display import IFrame
IFrame('file.html', width=1000, height=550)
Thomas K
  • 39,200
  • 7
  • 84
  • 86

1 Answers1

0

You probably want to pass your array as an URL parameter.

Say your array is {'a', 'b', 'c', 'd'} - you can do IFrame('file.html?param1=a,b,c,d', width=1000, height=550) and then fetch url parameters from javascript. It's up to you how you format your array as a text string tho.

About fetching url parameters : there is no standard way to do that in javascript but here is an implementation.

Then do whatever the you need/want with it inside demo().

Community
  • 1
  • 1
PinkTurtle
  • 6,942
  • 3
  • 25
  • 44
  • 1
    I am Calling it in this way, but not getting the params in js. IFrame('../net-vis/WebContent/html/index.html?abc=3', width=1200, height=800) – Harit Vishwakarma Jul 21 '16 at 14:55
  • Passing parameters like IFrame('file.html?param1=a,b,c,d', width=1000, height=550) does not work in practice! – xuancong84 Jun 26 '20 at 12:49