Background:
1. There are two jsp InvokeEService.jsp and trafficViolationMain.jsp.  InvokeEService.jsp is in domain “stg.www.gov.en” and  trafficViolationMain.jsp is in domain “services.www.gov.en”.2. Code “<iframe src=” http//services.www.gov.qa/TrafficViolationsWeb/trafficViolationMain.jsp”></iframe>” is in the InvokeEService.jsp for load eservice page.3. “services.www.goc.en” is an eservice from customer side So we can’t change anything on trafficViolationMain.jsp
Requirement
Dynamic adjust iframe’s height and width based on the content of iframe for not show scroll bar of iframe. Code Changed
1. changed the root domain by execute javascript “document.domain=www.gov.en” which locate in “InvokeEService.jsp” for InvokeEService.jsp and trafficViolationMain.jsp can communicate with each other.
“iframe.style.height = iframe.contentWindow.document.body.scrollHeight;” in “onload” event of iframe.What happen
1. There is a main menu displays complete in the page when we visit http://stg.www.gov.en/InvokeEService.jsp,It can display complete2. click one link in above page
the bottom of the content in iframe lost.AnalysisIt caused by javascript exception when the program execute to “iframe.style.height  = iframe.contentWindow.document.body.scrollHeight;”.So I did test as below1. execute javascript “alert (iframe.contentWindow);” It prompt a dialog and displays “[object]”
2. execute javascript “alert (iframe.contentWindow.document);” Nothing happened but there is a javascript error occurred .The error message is “Access is denied”Based on the above test result .I think the problem is iframe cross domain visit.
Please help me if you can resolve this issue.Thank you very much.
      
    

解决方案 »

  1.   

    我也是这么想的,看了很多的解决方案,基本上都是需要可以改写iframe加载的那个页面的内容才能实现跨域访问。但是这种eservice的没办法,郁闷啊。
      

  2.   

    because you have changed domain both two page,you can put the codes which thrown exception in a try catch block,when the iframe page load finished, the codes can be run normally