如何在按钮的onclick功能中给出双引号?

时间:2017-02-27 07:09:11

标签: javascript

在给出双引号后,它显示错误

我在infowindow中使用谷歌地图api代码在点击按钮时在iframe中打开一个页面。

(function(marker, data) {
    google.maps.event.addListener(marker, "click", function(e) {
      infoWindow.setContent(data.description + "<br>" + 
      " <input type='button' class='class' value='More Details' onclick=@'document.getElementById('i').src = 'HomePage.aspx';' />" + 
      '<iframe id="i" style="height:50%;width:100%;"></iframe>');
      infoWindow.open(map, marker);
    });

1 个答案:

答案 0 :(得分:1)

我不确定@ means的奇怪语法是什么。

我希望你的代码是

infoWindow.setContent(data.description + '<br/>'+
'<input type="button" class="class" value="More Details" onclick="document.getElementById(\'i\').src = \'HomePage.aspx\'" />'+
'<iframe id="i" style="height:50%;width:100%;"></iframe>');