0

I'm building an app with Browserify, so everything is packaged up into commonJS modules and separated out of the global name space, which is generally a great state of affairs.

I've had to open up another page inside of an iframe which opens as a modal in my app. Once the user saves his work inside of that page that page needs to call out to my app to tell it to close the modal.

The only way I know of to call outside of an iframe is to use parent.window. But I'm unclear how to get from the global namespace inside of the modules packaged up with browserify.

I have tried to assign a function to an identifier on the window object within one of my modules, but after the code runs, if I interrogate the window object, my function is not there.

I have tried to follow the example in this post, but I'm not having any luck.

Defining global variable for Browserify

Thanks

Community
  • 1
  • 1
jdavis
  • 8,255
  • 14
  • 54
  • 62

1 Answers1

0

All you have to do is assign the object explicitly to the window object and it will be there. For instance, with jQuery, you'd just make sure something like this was present in the code you're bundling with Browserify:

window.$ = window.jQuery = require('jquery');
YPCrumble
  • 26,610
  • 23
  • 107
  • 172