简体   繁体   English

在Google Map Infowindow内容中传递JavaScript变量?

[英]Passing a javascript var in google map infowindow content?

I want to pass a value in a javascript call from a google map infowindow. 我想在来自Google地图信息窗口的javascript调用中传递一个值。 Since this editor will not let me paste the code directly, I am hoping you get the idea from the description. 由于此编辑器不允许我直接粘贴代码,因此希望您从描述中得到启发。

I am setting the content of the infowindow with an html anchor that fires a javascript function, but I am unable to pass a var in the markup. 我正在使用触发javascript函数的html锚设置信息窗口的内容,但无法在标记中传递var。

a href=javascrpit:addcoupon() to a href=javascrpit:addcoupon(aVar). a href = javascrpit:addcoupon()到href = javascrpit:addcoupon(aVar)。

I have tried several syntax ways of doing it but can't accomplish it. 我尝试了几种语法方法来完成此操作,但无法完成。

Even though the function is called, I would like to add a variable to the javascript function call but am having no luck. 即使调用了该函数,我也想向javascript函数调用中添加一个变量,但是没有运气。 The value is simply named 'value'. 该值简称为“值”。

How could I pass that value in the addcoupon call? 如何在addcoupon调用中传递该值?

Thank you. 谢谢。

How about this 这个怎么样

In html: 在html中:

<a onclick="addcoupon()"></a>

Then in your js 然后在你的js中

addcoupon = function() {
val = document.getElementById("value");
// do whatever with value
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM