There is a modal window (simplified div.modal {position: absolute;}) This window can load various pages of the site, including those with js code.
There were several questions:
- How do I arrange for such windows document.redy
- How to avoid redeclare function (if they are written in tags <script> </ script>)
- How can I unload js, which is no longer needed (by closing the page)
- How do I refer to $ (document) only to the window that opened
All is desirable without eval.
As a solution, I still have one thought in turn: do everything through closures with a description of the basic prototypes for standard objects. For example, all the js code from a page is placed in a function where the document, window parameters are passed. But how to deal with loaded scripts?
(function (document, window){ //some code from modal page })(new MyDocument, new MyWindows);
Do I think in the right direction?