This shows you the differences between two versions of the page.
| — |
framesinpopups [2009/01/18 12:49] (current) admin created |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Accessing Frames in a Popup Window in JavaScript ====== | ||
| + | For various reasons, it is hard to access a (frameset) frame in a popup window that you just opened. So what you want to do is store information in the popup window and let it perform whatever action needed itself: | ||
| + | |||
| + | Parent window: | ||
| + | |||
| + | <code javascript> | ||
| + | popup = window.open(url,name,options); | ||
| + | popup.parameters = ... | ||
| + | </code> | ||
| + | |||
| + | Popup window: | ||
| + | |||
| + | <code html> | ||
| + | <frameset onload="performAction(top.parameters)"> | ||
| + | <frame ...> | ||
| + | </frameset> | ||
| + | </code> | ||
| + | |||
| + | If you actually need to access a frame, you should do it the same way. I.e. put the actual functionality in the frame window: | ||
| + | |||
| + | <code html> | ||
| + | <body onload="performFrameAction(window.frameParameters)"> | ||
| + | ... | ||
| + | </body> | ||
| + | </code> | ||