Javascript 将google地图api合并到chrome扩展/document.write的替代方案中
我正在尝试将谷歌地图api合并到我的chrome扩展中。但是,我发现清单版本2不允许Javascript 将google地图api合并到chrome扩展/document.write的替代方案中,javascript,google-maps,google-maps-api-3,google-chrome-extension,Javascript,Google Maps,Google Maps Api 3,Google Chrome Extension,我正在尝试将谷歌地图api合并到我的chrome扩展中。但是,我发现清单版本2不允许document.write。有什么办法可以解决这个问题吗?在加载Maps API时使用回调URL参数,它不会使用document.write()。在普通网页中,您可以这样做: function initMap() { // Create the map object here as usual } function loadMapsAPI() { var script = document.c
document.write
。有什么办法可以解决这个问题吗?在加载Maps API时使用回调
URL参数,它不会使用document.write()
。在普通网页中,您可以这样做:
function initMap() {
// Create the map object here as usual
}
function loadMapsAPI() {
var script = document.createElement( 'script' );
script.src =
'http://maps.googleapis.com/maps/api/js' +
'?sensor=false&callback=initMap';
document.body.appendChild( script );
}
我不知道这将如何与Chrome扩展交互,但这就是它在常规网页中的实现方式