1

I use this html to load the bing map scripts:

<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>

in firefox: script loads and adds another script tag to head, then the second script loads (can see in firebug Net tab):

<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: i hook to page.onResourceRequested and print request url. result is that only the first script is requested, veapicore.js is not requested for reason unknown to me.

what is happening here?

Huangism
  • 16,278
  • 7
  • 48
  • 74
taminov
  • 591
  • 7
  • 23
  • 1
    Please register to the [`onConsoleMessage`](http://phantomjs.org/api/webpage/handler/on-console-message.html) and [`onError`](http://phantomjs.org/api/webpage/handler/on-error.html) events. Also please register to the [`onResourceError`](http://phantomjs.org/api/webpage/handler/on-resource-error.html) and [`onResourceTimeout`](http://phantomjs.org/api/webpage/handler/on-resource-timeout.html) events. Maybe there are errors. – Artjom B. Oct 30 '14 at 23:14
  • post, i'll mark it as an answer – taminov Nov 02 '14 at 09:13
  • thanks I found the solution using your advice. i already used the onError and onConsoleMessage before but the error was hidden in onResourceError - SSL thing. --ssl-protocol=any. http://stackoverflow.com/questions/12021578/phantomjs-failing-to-open-https-site%E2%80%8C%E2%80%8B – taminov Nov 02 '14 at 09:19
  • 1
    I won't post it, since this would duplicate the answer. It is better to link your question to the other question. See [Why are some questions marked as duplicate?](http://stackoverflow.com/help/duplicates) – Artjom B. Nov 02 '14 at 09:20

1 Answers1

0

I believe this is the same issue that RequireJS has. In web browsers, when you dynamically load in a script, it can't dynamically load other scripts if the scripts are on a different domain. This is a security thing.

Just load the script tag like normal, or take a look at this blog post: http://rbrundritt.wordpress.com/2011/11/20/bing-maps-v7-control-lazy-loader/

rbrundritt
  • 16,570
  • 2
  • 21
  • 46