0

I have an instance of my class..

var controller = new (function () {
     // Contains lot of methods
});

Is it possible that i can make the instance of this Object across all Windows. Without including this file in other pages, i can call the instance of this Object every where.

2
  • 1
    It is not possible to access across windows. That's a security protection mechanism on all modern browsers. Otherwise, one malicious site can modify info from another window. In your case, you'll need to put the shared object in the server and update via XHR. Commented Jun 21, 2011 at 10:42
  • No you can't do that. You can however inject the object into windows that are known to you and you have access to (same origin policy). Commented Jun 21, 2011 at 10:43

1 Answer 1

2

Without including this file in other pages, i can call the instance of this Object every where.

No you cannot. There are no cross window Javascript objects as far as I know and I assume that there would not be for security reasons. Though I guess parent windows can talk to child windows. So you could append something to a parent window and pass data that way but I would not recommend it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.