There are totally 3 relevant files involoved.
- The main aspx file ( which hosting iframe of another site. (Under domain main.com) Notice: you should add src="http://sub.com/index.jsp" in the iframe.

- The transmission html file (grAutoSize.htm) which link the iframe part with main site. (Under domain main.com)

- The hosting site JS file (refer.js) which referred by sub domain pages (Under domain sub.com). It could be different tech platform such as JSP/PHP/ASP. Here is index.jsp.
Notice: the variable urlC should be main.com/grAutoSize.htm.
- You don't need add document.domain = xxx.com for this solution. Also it was tested to working with IE7, IE8, Mozilla Firefox 3, Google Chrome 2, Safari 4.