2017-02-27 58 views
3

在给出双引号后它显示错误如何在按钮的onclick函数中使用双引号?

我在infowindow中使用google map 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' [email protected]'document.getElementById('i').src = 'HomePage.aspx';' />" + 
     '<iframe id="i" style="height:50%;width:100%;"></iframe>'); 
     infoWindow.open(map, marker); 
    }); 
+2

什么是'的onclick = @ '的document.getElementById(' I ')HomePage.aspx SRC = '';''怎么办呢? – mplungjan

+0

点击按钮后,Homepage.aspx将在ID为“i”的iframe中打开。 – Swadesh

回答

1

我不确定你用@表示你的奇怪的语法。

我希望你的代码

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>');