Everything is achievable through technology

Random Position

<script type=”text/javascript”>
function switchPos(obj)
var divobj = document.getElementById(‘div1’)
var x = divobj.offsetHeight – obj.height – 5;
var y = divobj.offsetWidth – obj.width – 5;

var randomx = Math.floor(Math.random()*x+1);
var randomy = Math.floor(Math.random()*y+1); = randomx + ‘px’; = randomy + ‘px’;
<div id=”div1″ style=”width: 800px;height:500px; background: red;”>
<img src=”image.jpg” style=”position:relative;” onmouseover=”switchPos(this);” onmouseout=”switchPos(this);”/>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s