You can do this with this jQuery animation plugin . Of course, it is assumed that you are using jQuery. If your javascript skills are not as strong as you would like, jQuery is a good place to start. Do not get me wrong, this is not a substitute for learning pure javascript, but for you it is a lot.
Color animation based on the John Resig color animation plugin, but adds rgba support so you can get your transparency. You can also animate text colors and borders.
To get the photo id from the query string, you can use such a function (which I found in SO here ), but I personally find the def (default) argument is useful when I want to set the return value automatically when name not found in the query string :
function getParameterByName(name, def) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)", regex = new RegExp(regexS), results = regex.exec(window.location.href); if(results == null) return def; else return decodeURIComponent(results[1].replace(/\+/g, " ")); }
Put this anywhere in your script tag. Then, to get your parameter and release it, place it where you need it (for example, the head tag). Here, I assume that you will want to do this using the Ready document (when the DOM elements of the page are loaded), but you can also postpone it a bit or wait until the hover or some other event .:
$(document).ready(function() { var flashDiv = getParameterByName("photoID", false); if(flashDiv!==false) { $("#"+flashDiv).animate({backgroundColor: '#19426E'}, 2000); $("#"+flashDiv).animate({backgroundColor: 'rgba(0,0,0,0)'}, 2000); } });
If you want to postpone this 2 seconds after the page loads:
$(document).ready(function() { var flashDiv = getParameterByName("photoID", false); if(flashDiv!==false) { setTimeout(function() { $("#"+flashDiv).animate({backgroundColor: '#19426E'}, 2000); $("#"+flashDiv).animate({backgroundColor: 'rgba(0,0,0,0)'}, 2000); }, 2000); } });
And if you want to wait for the user to go to this (but only once):
$(document).ready(function() { var flashDiv = getParameterByName("photoID", false); if(flashDiv!==false && !flashed) { $("#"+flashDiv).one("mouseover", function() { $(this).animate({backgroundColor: '#19426E'}, 2000); $(this).animate({backgroundColor: 'rgba(0,0,0,0)'}, 2000); }); } });
Update after comment:
Getting your photo after # is even easier (you won’t need the getParameterByName function, of course):
$(document).ready(function() { var photoId = document.location.href.split("#")[1]; if(photoId!==undefined) { $("#"+photoId).animate({backgroundColor: '#19426E'}, 2000); $("#"+photoId).animate({backgroundColor: 'rgba(0,0,0,0)'}, 2000); } });