Click here to Skip to main content
15,902,846 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionExtJS Pin
RameshChTulal29-May-12 1:28
RameshChTulal29-May-12 1:28 
AnswerRe: ExtJS Pin
thatraja4-Jun-12 17:18
professionalthatraja4-Jun-12 17:18 
QuestionUpdate DIV text by Javascript Pin
iucaa27-May-12 10:06
iucaa27-May-12 10:06 
AnswerRe: Update DIV text by Javascript Pin
Sandeep Mewara27-May-12 19:58
mveSandeep Mewara27-May-12 19:58 
GeneralRe: Update DIV text by Javascript Pin
iucaa29-May-12 10:20
iucaa29-May-12 10:20 
Questionimplement double click event on Div child elements Pin
Steve Holdorf27-May-12 2:18
Steve Holdorf27-May-12 2:18 
AnswerRe: implement double click event on Div child elements Pin
Steve Holdorf28-May-12 7:14
Steve Holdorf28-May-12 7:14 
QuestionJava Script moveing a picture around the screen Pin
Boaz Yaari26-May-12 5:00
Boaz Yaari26-May-12 5:00 
Hello,
I'm trying to move a picture around my screen randomly.

Here is my code:

XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript: Moving an Image</title>
<script type="text/javascript">
var i = 0;

function Init()
{
    var elem = document.getElementById("ss");
    var move = parseInt(elem.style.marginTop+10);
        elem.setAttribute("style", "marginTop:" + move.toString() + "px");
        elem.setAttribute("style", "marginLeft:" + move.toString() + "px");
        elem.setAttribute("style", "marginBottom:" + move.toString() + "px");
        elem.setAttribute("style", "marginRight:" + move.toString() + "px");
        setInterval("Init()",1000);




}
function  backToCenter()
{
    var elem = document.getElementById("ss");
    elem.style.marginTop="200px";
    elem.style.marginRight="200px";
    elem.style.marginBottom="200px";
    elem.style.marginLeft="400px";
}

</script>


<style>
#box
{
   width: 500px;
   height: 300px;
   position: relative;
   margin: 20px auto 0px auto;
   border: 5px outset #000;
   overflow: hidden;
}

.image
{
   position: absolute;
   z-index: 100;
}
</style>
</head>

<body onload="Init()">
<div  id="ss"style="height: 200px; width: 500px;"><img class="image" id="img1" src="beer-logo.jpg" height="50px" width="50px"/></div>
</body>
</html>


but the picture doesnt move, i cant figure out how to do this.

any help would be more than thankfull.


cheers.
AnswerRe: Java Script moveing a picture around the screen Pin
Ali Al Omairi(Abu AlHassan)26-May-12 20:57
professionalAli Al Omairi(Abu AlHassan)26-May-12 20:57 
GeneralRe: Java Script moveing a picture around the screen Pin
Boaz Yaari27-May-12 10:43
Boaz Yaari27-May-12 10:43 
GeneralRe: Java Script moveing a picture around the screen Pin
BobJanova28-May-12 23:34
BobJanova28-May-12 23:34 
GeneralRe: Java Script moveing a picture around the screen Pin
Boaz Yaari27-May-12 11:22
Boaz Yaari27-May-12 11:22 
GeneralRe: Java Script moveing a picture around the screen Pin
Ali Al Omairi(Abu AlHassan)28-May-12 0:38
professionalAli Al Omairi(Abu AlHassan)28-May-12 0:38 
AnswerRe: Java Script moveing a picture around the screen Pin
Ali Al Omairi(Abu AlHassan)31-May-12 7:40
professionalAli Al Omairi(Abu AlHassan)31-May-12 7:40 
GeneralRe: Java Script moveing a picture around the screen Pin
enhzflep31-May-12 10:38
enhzflep31-May-12 10:38 
GeneralRe: Java Script moveing a picture around the screen Pin
Ali Al Omairi(Abu AlHassan)1-Jun-12 1:15
professionalAli Al Omairi(Abu AlHassan)1-Jun-12 1:15 
AnswerRe: Java Script moveing a picture around the screen Pin
enhzflep29-May-12 10:41
enhzflep29-May-12 10:41 
QuestionHow to change mouse cursor in jQuery UI resizable plugin? Pin
Tesic Goran25-May-12 0:06
professionalTesic Goran25-May-12 0:06 
AnswerRe: How to change mouse cursor in jQuery UI resizable plugin? Pin
Ali Al Omairi(Abu AlHassan)29-May-12 5:08
professionalAli Al Omairi(Abu AlHassan)29-May-12 5:08 
QuestionA Unique Problem - Ignoring Placing Page on Back Button History Pin
OrangeV24-May-12 5:40
OrangeV24-May-12 5:40 
AnswerRe: A Unique Problem - Ignoring Placing Page on Back Button History Pin
Sandeep Mewara24-May-12 9:02
mveSandeep Mewara24-May-12 9:02 
QuestionHow to make the text box draggable using jQuery? Pin
Tesic Goran23-May-12 8:45
professionalTesic Goran23-May-12 8:45 
AnswerRe: How to make the text box draggable using jQuery? Pin
Vitaly Tomilov24-May-12 16:13
Vitaly Tomilov24-May-12 16:13 
AnswerRe: How to make the text box draggable using jQuery? Pin
ZurdoDev25-May-12 8:47
professionalZurdoDev25-May-12 8:47 
Questionfinding a substring match at the beginng of a of another string. Pin
Steve Holdorf22-May-12 7:16
Steve Holdorf22-May-12 7:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.