Javascript googlemap api document.write()不';行不通

Javascript googlemap api document.write()不';行不通,javascript,google-maps-api-3,Javascript,Google Maps Api 3,出现警报地址为什么 i can't understand `alert(results[1].formatted_address); // Work Fine` document.write(结果[1]。格式化的_地址+“”);//没用 网页上没有显示?只有在浏览器构建DOM时,才能安全使用document.write()API。在来自mapsapi的回调中使用它意味着当它运行时,DOM已经完成。此时,调用document.write()意味着应该删除DOM并准备一个新的DOM 如果需要添

出现警报地址为什么

i can't understand `alert(results[1].formatted_address); // Work Fine` 
document.write(结果[1]。格式化的_地址+“
”);//没用
网页上没有显示?

只有在浏览器构建DOM时,才能安全使用
document.write()
API。在来自mapsapi的回调中使用它意味着当它运行时,DOM已经完成。此时,调用
document.write()
意味着应该删除DOM并准备一个新的DOM


如果需要添加内容,请使用DOM操作API和/或
innerHTML

使用document.write不太好。更好地操作DOM,比如
document.getElementById('id')。innerHTML=results[1]。格式化的地址+“
i can't understand `alert(results[1].formatted_address); // Work Fine` 
document.write(results[1].formatted_address+"<br>"); // didn't work