2014-10-30 94 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