简体   繁体   English

Javascript-外部库/文件参考

[英]Javascript- external library/ file reference

When I referance my local files like this it works: 当我引用这样的本地文件时,它将起作用:

 var $referances =  $("head"); 

$referances.append('<script type="text/javascript" src="javaScript/geoMaps/Main.js"></script>');
$referances.append('<script type="text/javascript" src="javaScript/geoMaps/Dealer.js"></script>');
$referances.append('<script type="text/javascript" src="javaScript/geoMaps/MapController.js"></script>');
$referances.append('<script type="text/javascript" src="javaScript/geoMaps/Communicator.js"></script>');

BUT when I try to include an external library, it doesnt include. 但是,当我尝试包括外部库时,它不包括在内。 Like: 喜欢:

$referances.append('<script type="text/javascript" src="http://maps.google.com/maps/api/js\?libraries=geometry&sensor=false"></script>');

What could be the problem here ? 这可能是什么问题? Thanks in advance. 提前致谢。

Try: 尝试:


var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = "http://maps.google.com/maps/api/js?libraries=geometry&sensor=false";
$("head").append( script );

This works just fine: 这很好用:

<script src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=false"></script>

This is not a javascript problem... There are other factors at work here. 这不是JavaScript问题。这里还有其他因素在起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM