Click here to Skip to main content
15,887,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I own a website, say "http://a.mydomain.com". I have a webmail for my domain at "http://webmail.mydomain.com".

I want to display the webmail in an iframe inside my website. I provided a link in website which opens webmail in an iframe inside a page in my website. Both have same login credentials. I already managed to auto-login into webmail using my site's login credentials.

Problem:
When iframe is loaded in my website, there is permission issue related to cross domain. So the webmail keeps on loading... and shows a continuous progress bar.
Console error shows "SecurityError: Permission denied to access property "xxx" on cross-origin object"

But when I open webmail in a new tab on clicking link then webmail loads perfectly in new tab.

I want to display webmail inside an iframe in my website's page. How do I do that? I have control on my site "http://a.mydomain.com" but not on "http://webmail.mydomain.com".

Thanks!

What I have tried:

I have found the option to execute below line on both websites:
document.domain = 'mydomain.com'

But I do have control only on my website and not on webmail.
Posted
Comments
[no name] 1-Aug-17 6:20am    
What you posted should work in theory. My guess is that the webmail page at http://webmail.mydomain.com is making calls out to another domain and it's this that is being blocked?
Gautam Raithatha 1-Aug-17 7:21am    
Further I found that javascript in http://webmail.mydomain.com has "top.$(..."
When I open in new tab, "top" refers to page of webmail, while in iframe, "top" refers to webpage in my website.

So I think error comes here when page in iframe tries to find and access control in "top.$(..", which my website's page, and so it does not find any such control.
[no name] 1-Aug-17 8:07am    
I think if you don't have any control of the code on that page then it's going to be very difficult to get it working :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900