Cross-domain JavaScript code with sibling sub-domains

后端 未结 2 1863
既然无缘
既然无缘 2021-01-06 00:22

I have two web applications setups:

david.example.com and john.example.com

David opens a new window to John:



        
相关标签:
2条回答
  • 2021-01-06 00:48

    You can always use iframes for cross domain communication and send messages via the hashbangs. See this for an example. It's basically the workings of stuff like Facebook connect. If one app opens the other window I'm guessing you can do that with normal windows as well.

    0 讨论(0)
  • 2021-01-06 01:05

    You should be able to do this, as long as you set document.domain on both DOM's.

    document.domain = location.host.replace(/^.*?([^.]+\.[^.]+)$/g,'$1');
    

    Credited to Martin Jespersen

    0 讨论(0)
提交回复
热议问题