2014-10-30 122 views
1

我用这个网站加载了Bing地图脚本:Bing地图不加载

<html><head> 
    <script src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1"  type="application/javascript" ></script> 
</head><body></body></html> 
在Firefox

:脚本负荷,并增加了另一个脚本标签头,那么第二个脚本负载(可以在Firebug Net标签看):

<html><head> 
    <script src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1"  type="application/javascript" ></script> 
    <script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/v7.0/7.0.20140904153057.64/js/en-us/veapicore.js"> 
</head><body></body></html> 

in phantomjs:我钩到page.onResourceRequested并打印请求url。结果是只有第一个脚本被请求,veapicore.js没有被请求我不知道的原因。

这里发生了什么事?

+1

请注册到['onConsoleMessage'](http://phantomjs.org/api/webpage/handler/on -console-message.html)和['onError'](http://phantomjs.org/api/webpage/handler/on-error.html)事件。还请注册['onResourceError'](http://phantomjs.org/api/webpage/handler/on-resource-error.html)和['onResourceTimeout'](http://phantomjs.org/api/网页/处理程序/ on-resource-timeout.html)事件。也许有错误。 – 2014-10-30 23:14:31

+0

后,我会将其标记为答案 – taminov 2014-11-02 09:13:51

+0

谢谢我使用您的建议找到了解决方案。我之前已经使用过onError和onConsoleMessage,但是错误被隐藏在onResourceError - SSL事件中。 --ssl协议=任何。 http://stackoverflow.com/questions/12021578/ph​​antomjs-failing-to-open-https-site%E2%80%8C%E2%80%8B – taminov 2014-11-02 09:19:00

回答

0

我相信这与RequireJS有同样的问题。在Web浏览器中,当您动态加载脚本时,如果脚本位于不同的域中,则无法动态加载其他脚本。这是一件安全的事情。

只加载脚本标记像正常的,或者看看这个博客帖子:http://rbrundritt.wordpress.com/2011/11/20/bing-maps-v7-control-lazy-loader/

+0

加载*脚本标记*的正常*方法是什么? – 2014-10-31 08:17:44

+0

使用脚本标记: rbrundritt 2014-10-31 12:32:09

+0

这正是OP做了,它不起作用。 – 2014-10-31 12:35:41