简体   繁体   中英

Parent access to child javascript data

Customer has page with navigation that detects when changes were made in a grid of data, and reminds the user to save their data before they leave the page. If the user becomes confused about what they are doing or suspects they have made a lot of data entry errors, they may also just cancel their changes and start over.

The customer has a login system in which they place these pages, via iframes. The login system is to have a new sub menu to navigate these pages (call them into the iframe), replacing the on-page navigation on the child pages themselves.

The grids on these pages sets a flag, to indicated data in at least one grid cell was changed. On page navigation has no trouble checking the flags and reminding the user that they have unsaved data in one of the grids.

How would the menu from the parent page check to see if these flags were set by the grids on the child pages? The flags are currently in an array, with the number of the grid as the index.

Most cells do this, or call another function that calls this function

--------------------------------------------------------
. . . onchange='make_input_changed(grid_NM)' . . .

-------------------------------------------------------

// up to 6 grids on page in this example.
var input_changed = new Array('false', 'false', 'false', 'false', 'false', 'false');

// for each grid, set a flag indicating that data on the current grid page has changed
function make_input_changed(grid_NM) { input_changed[grid_NM] = true; } 


-----------------------------------------------------

Can the parent access the child flags ?

**Can the child call a parent function to keep track of changes ?

A frame is just a 'special' window.

You can use window.top or window.parent to navigate around the hierarchy of windows and frames. As long as your frames are in the same domain, you should be OK.

You can access variables in another frame:

parent.Frame2.varInFrame2 = 100;

... and you can invoke functions in another frame:

parent.Frame2.notifyLogin(id)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM