Is it possible to use jQuery in a second window on my page?
I’ve tried something like this:
var $ = document.parent.$;
But that doesn’t seem to work.
Any other ideas? I can’t load the framework again.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
when its in a frame or external window then the library needs to be in that HTML, even if you load() html in through a modal dialog. This is the case if your using jquery/javascript within those elements to manipulate anything outside of them. If your not and all you wish to do is do something from the main window to the child windows frame or otherwise you would have to name the windows/frames.
Reason I say this is cause the DOM is already rendered at that point. You can add javascript dynamically as well with javascript after the DOM is rendered but for the sake of ease I would go with the above mentioned, as theres no real harm calling in jquery more than ones in a scenario like this, or at least no harm I can think of at the moment
On the same note this will also be helpful for you most likely as well:
jQuery select element in parent window