You can use a function like:
Code:
function change(id, html){
document.getElementById( id ).innerHTML = html;
}
that is on the opener from the child window like so:
Code:
window.opener.change('div2', 'whatever');
But if you mean you want to put things back the way they were (in your example), it would be:
Code:
window.opener.change('div2', 'How cool is blue? <a onclick="change(\'div3\',\'I love the color blue!\')">Click here</a>.');
You could get creative and store the original values as properties of the function itself:
Code:
function change(id, html, restore){
if(!change[id] && !restore)
change[id] = document.getElementById( id ).innerHTML;
else if (change[id] && restore)
document.getElementById( id ).innerHTML = change[id];
if (!restore)
document.getElementById( id ).innerHTML = html;
}
Then if the innerHTML had been changed, this would restore it (from the child window):
Code:
window.opener.change('div2', '', true);
The function would still also work with its original syntax for its original purpose.
Bookmarks