开发者

how to pass a javascript variable to onMouseOver event

开发者 https://www.devze.com 2023-04-04 11:22 出处:网络
How can i use a js variable in mouseOver event? Here is my code: <script type=\"text/javascript\">

How can i use a js variable in mouseOver event?

Here is my code:

   <script type="text/javascript">
              window.String1 = <%=GetLocalResourceStringEscaped("String1")%>;
              window.String2 = <%=GetLocalResourceStringEscaped("String2")%开发者_运维知识库>;
              </script>
              <label runat="server" id="labelWeight" onmouseout="HelpOut(this);" onmouseover="Help(this,window.String1,window.String2);">
                  <asp:Localize ID="LocPWeight" runat="server" meta:Resourcekey="ProductWeightInGrams"
                            Text="Product Weight in Grams"></asp:Localize>
                </label>

and it looks like it doesn't work this way :).

Thanks. !


Try this:

onmouseover = 'Help(this,<%=GetLocalResourceStringEscaped("String1")%>, <%=GetLocalResourceStringEscaped("String2")%>);';


I figure it out i needed qoutes:

        window.String1 = <%=GetLocalResourceStringEscaped("String1")%>;

has to be

        window.String1 = '<%=GetLocalResourceStringEscaped("String1")%>';

Your soulutions didn't work. If the label contains a runat="server" attribute "<%= %>" tags are not allowed. That's why i didn't use it in the first place, but i forgot to mention it. Sorry for that.

Thanks you for your answers!


Try this:

onmouseover='function(){Help(this,<%= GetLocalResourceStringEscaped("String1") %>,<%= GetLocalResourceStringEscaped("String2") %>);}'
0

精彩评论

暂无评论...
验证码 换一张
取 消