[Javascript] What was last rollover?

Tim Lewis twlewis at softhome.net
Thu Oct 4 13:43:16 CDT 2007


This might be a little overkill, but it saves it as a cookie.
Tim
_____

<html><head>
<script language=JavaScript src="doArray.js"></script>
<script language=JavaScript>
<!--
function SaveMouseOver(cImg) {
var cookiename="imgmouseover";
if (readCookie(cookiename) != null) {
	eraseCookie(cookiename);
	}
createCookie(cookiename,cImg,30);

alert ("The cookie value is "+readCookie(cookiename));
}
//________________________________________________________________
function createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
//________________________________________________________________
function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}
//________________________________________________________________
function eraseCookie(name)
{
  createCookie(name, "", -1);
}
//________________________________________________________________
-->
</script>
</head>
<body>
<form id=myform>
<img id=imgMyImage1 src="Scooby_color_16.jpg"
OnMouseOver="SaveMouseOver(imgMyImage1.id)"
<p>
<img id=imgMyImage2 src="Scooby_color.jpg"
OnMouseOver="SaveMouseOver(imgMyImage2.id)"

</form>
</body>
</html>


________
> Hi gang:
>
> I have three images on a web page with a css rollover condition, such as:
>
> img1:hover
> {
> border: 1px solid red;
> }
>
> img2:hover
> {
> border: 1px solid blue;
> }
>
> img3:hover
> {
> border: 1px solid green;
> }
>
> If the user moves his/her cursor over an image, then the border's
> corresponding color changes -- no problems there.
>
> But, how can I determine which image was subject to the *last* rollover?
>
> Is there any way to do this?
>
> TIA.
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript
>





More information about the Javascript mailing list