I’d like to be able to take the DOM structure from an existing page and then separate certain elements across different browser windows. When doing so, I’d like to retain the same session across each of these browser windows. Is this possible? And if so, how would one go about doing this?
To give more clarity, here’s an example of how this would be used:
1) I login to a site and create the session.
2) The site has various widgets on the page. Some of the widgets I need to use, some I do not. Instead of hiding the ones I don’t need via CSS, I’d rather extract the ones I do need into separate windows. Then I could arrange those individual widget windows across my desktop as much as I want.
Any way to do this? Thanks.
The window object is not part of the DOM. It is a host object implemented as the "global object" to complete an ECMAScript implementation. It has its own standard which is available from the W3C.
The window object is supported by all browsers. It represents the browser's window. All global JavaScript objects, functions, and variables automatically become members of the window object. Global variables are properties of the window object.
The window object represents an open window in a browser. If a document contain frames (<iframe> tags), the browser creates one window object for the HTML document, and one additional window object for each frame.
I’d like to retain the same session across each of these browser windows.
Sessions are not maintained by the DOM. They exist in cookies and maybe javascript state.
I’d like to be able to take the DOM structure from an existing page and then separate certain elements across different browser windows.
There are two options, DOM nodes can be directly transplanted from one document to via adoptNode but that requires direct access between the different javascript global contexts, which is only available via frames or window.opener, i.e. when one window directly spawned the other. Note that this just moves DOM nodes, not any state or listeners associated with them.
The alternative is serializing them to HTML or XML and sending the serialized form to another window via various communication mechanisms such as postMessage
or channels.
Since you say widgets I guess there is some javascript associated with them. That javascript will have to be rewritten to communicate across window boundaries in a similar fashion as you move the DOM nodes themselves across window boundaries.
If your frontend is implemented as MVC or similar patterns you should just move the model to a different window and rematerialize the view instead of moving the dom directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With