JabbaTheNut
Programmer
Can someone provide some code examples for pre-loading images for an Image Button rollover (i.e., "onmouseover", "onmouseout", etc.). I have tried following code unsuccessfully:
This is the javascript I am currently using...
<script language="javascript>
// Pre-load the rollover images
function pgInit ()
{
---image1 = New Image();
---image2 = New Image();
---image1.src = "images/myimage_over.gif"
---image2.src = "images/myimage_out.gif"
}
// Provide image to use, given the state
function rollImage (state)
{
---switch(state)
---{
------case "over":
---------image1.src;
------case "out":
---------image2.src;
---}
}
</script>
I have also included the following in my VB code-behind file under the Page_Load procedure to add the "onmouseover" and "onmouseout" events to the Image Button control on the rendered page...
myImgBtn.Attributes.Add("onmouseover", "this.src=rollImage('over');"
myImgBtn.Attributes.Add("onmouseout", "this.src=rollImage('out');"
The above code does not work. Can someone either correct my above code, tell me that the code appears correct and the problem must be something else, or suggest a different method? I want to pre-load images and use them for an image rollover for an Image Button.
Thanks in advance Game Over, Man!
This is the javascript I am currently using...
<script language="javascript>
// Pre-load the rollover images
function pgInit ()
{
---image1 = New Image();
---image2 = New Image();
---image1.src = "images/myimage_over.gif"
---image2.src = "images/myimage_out.gif"
}
// Provide image to use, given the state
function rollImage (state)
{
---switch(state)
---{
------case "over":
---------image1.src;
------case "out":
---------image2.src;
---}
}
</script>
I have also included the following in my VB code-behind file under the Page_Load procedure to add the "onmouseover" and "onmouseout" events to the Image Button control on the rendered page...
myImgBtn.Attributes.Add("onmouseover", "this.src=rollImage('over');"
myImgBtn.Attributes.Add("onmouseout", "this.src=rollImage('out');"
The above code does not work. Can someone either correct my above code, tell me that the code appears correct and the problem must be something else, or suggest a different method? I want to pre-load images and use them for an image rollover for an Image Button.
Thanks in advance Game Over, Man!