回答

2

加載Google Maps API時使用callback 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); 
} 

Documentation

Example

我不知道如何做到這一點有一個Chrome擴展互動,但這是它是如何在做定期的網頁。