Put A and B with the same domain, different subdomain is fine. Then in the iframe A, you can call parent.function_name (parameter1, parameter 2). If you need to call that function very often, you may want to do this :
function p(data, div_id){parent.p(data, div_id);}
then in iframe A, you can just call p(data, div_id), which will actually call page B's function. I have used this a lot of comet streaming. If you are interested, you may read this, which basically use iframe to communicate with data:
http://www.shanison.com/2010/05/10/stop-the-browser-“throbber-of-doom”-while-loading-comet-forever-iframe/