如何将外部网站链接到内部javascript页面

I have a website lets call it example.com , it is hosted at an external hosting provider. On the site I have a page http://example.com/msg.php that needs to reference a JavaScript from an intranet site lets say running on example_intranet.com, so I have a script reference like..

 <script src="http://example_intranet.com/js/messaging.js" type="text/javascipt">

I'm aware of cross-domain security issues and have setup the necessary CORS on the example.com site and pages.

When you visit http://example.com/msg.php from OUTSIDE the company network (example_intranet.com) everything works as expected, but when you visit the same page from within (INSIDE) the network the page doesn't appear to resolve the javascript include ..

any suggestions on how to fix this?That is to be able to have the reference javascirpt work from inside the network.

I'm guessing this is a DNS issue, not about code. The intranet URL domain likely resolves to a different "internal" IP address when you are on the company network, and when you are outside it resolves to a public IP address.

Theoretical scenario:

When you are in the company network, the intranet URL gets resolved to a local IP, like 192.x.x.x or 10.x.x.x. SO when you visit your page on the external host your machine is trying to find the javascript file using that internal IP, but it might be looking for it inside the network of the external host, and won't find it.

As an experiment, try changing the path to your javascript file to use the public IP of that intranet URL instead of the domain name.