Reputation: 2273
Is it possible to fire events picked up by a separate browser window? With JavaScript perhaps.
i.e. if my website opened up another window to display summary product information, would it be possible to notify that window to update when a different product is selected in the main window?
Needs to work in IE, but doesn't need to work on Chrome or other browsers.
Upvotes: 2
Views: 1541
Reputation: 13557
There are a couple of options.
<iframe>
(e.g. through window.frames
, or window.parent
from the iframe's POV) or if the target is a window opened by the current window through window.open()
or window.opener
from the popup's POV.window.event
and browsers' local storage capabilites to simulate passing events between browsers. This is nothing you'd want to use in a production environment, though.German fellows may want to check out Kommunikations-APIs in HTML5 - Welche wann nutzen?
Upvotes: 3
Reputation: 328574
Use code like this:
Parent window
var func = function() {...}
child = window.open(...)
Child window
window.opener.func(); // Call function in parent window
You can also call function in the child window from the parent but there is one problem: You must wait until the child window has finished loading; window.open()
is asynchronous.
More details: Accessing parent window from child window or vice versa using JavaScript
Upvotes: 4
Reputation: 16971
Yeah, that would be possible if the window with product information would be open using window.open method in parent window.
That way you can induce communication between those two (without, strictly speaking, events) but with some extra code that's possible.
Upvotes: 0