doufei6456 2015-05-14 15:46
浏览 138

如何将外部网站链接到内部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.

  • 写回答

1条回答 默认 最新

  • dsp1836 2015-05-14 16:11
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)