【发布时间】:2010-12-30 19:38:56
【问题描述】:
预期:在 Google 地图标注框中看到 1-5 颗星
实际:页面闪烁并在页面顶部仅显示一长串星星.
我怀疑我不应该使用 document.write?
<html>
<head>
<script type="text/javascript">
//some Google Maps API code
function showstar(x)
{
var i = 0;
while (i < x)
{
document.write("<img src=\"img/star.gif\" width=\"15\" height=\"15\" />");
i++;
}
}
var html = "Review stars: " showstar(star)
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 700px; height: 500px"></div>
</body>
</html>
【问题讨论】: