Interaction between pages is only allowed if one page is a child of another, in other words the second page was launched by the first.
For the parent to access a child:
function GetFrameByLocation(locationName) {
for (var x = 0; x < window.frames.length; x++) {
if (window.frames[x].location.href.indexOf(locationName) > 0)
return window.frames[x];
}
return null;
}
var frame = GetFrameByLocation("p2");
frame.window.document - this is the DOM for p2.
for the child to access the parent:
parent.window.document