Avatar of DeHaynes
DeHaynes

asked on 

How to toggle an Image control from Cross-Browser Javascript

I am trying to change an asp:image controls imageUrl from javascript.  My code is below:

function MakeInfoRequired(ImageControl, MakeRequired)
{
      var infoButton = document.getElementById(ImageControl);
      if (infoButton)
      {
            var ImgSource;
            if (MakeRequired == true)
            {
                  ImgSource = "/templates/images/required_info_button.gif";
            }
            else
            {
                  ImgSource = "/templates/images/info_button_reduced.gif";             }
            infoButton.src = ImgSource;
      }
}

This works fine in Internet Explorer but I am trying to make it compatible with Netscape & Firefox.  Specifically Netscape 8.1+ and Firefox 2+.  I have tried them both and this doesn't work.  I am using ASP.Net 1.1, C#.

I cannot find any documentation on how to do
Web BrowsersJavaScriptASP.NET

Avatar of undefined
Last Comment
DeHaynes

8/22/2022 - Mon