
Originally Posted by
satori83
I have seen some sites that have a call to action with some sort of image, like an arrow,etc., and after your on the page for a few seconds it will wiggle or point in the direction they want you to look in.
An animated gif would always work but the JS solution is pretty trivial. Just substitute your own image:
Code:
<!DOCTYPE HTML>
<html>
<head>
<title>Poxy Element Vibrator</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type='text/css'>
body{background-color:#00f}
#g_arrow{ position:fixed; bottom:20px;right:20px; margin:0 10px 0 10px }
</style>
</head>
<body>
<img src='greenrightarrow.gif' d='g_arrow' >
<script type='text/javascript'>
function cycleMargin( imgId, defMargin, offsetMargin )
{
var elem = document.getElementById( imgId ),
displaced = false;
function nudge()
{
elem.style.margin = ( displaced ^= true ) ? defMargin : offsetMargin;
setTimeout( nudge, displaced ? 100 + Math.random() * 500 : 50 );
}
nudge();
}
cycleMargin( 'g_arrow', '0 10px 0 0', '0 0 0 10px' );
</script>
</body>
</html>
Bookmarks