GooS
Azrael
- Reaction score
- 154
Hi, some help required.
I want the background position to be movable. so when I click the button I want the background poisiont to move 1px upwards and here's what I got.
(This is a shoretened version without all the rest that isn't about this function)
Now this does absolutely nothing, and I found very little about getting the backgroundPosition value, only a whole lot about setting it.
So I ask of you, possibilities?, have I done something very stupid ?
I want the background position to be movable. so when I click the button I want the background poisiont to move 1px upwards and here's what I got.
(This is a shoretened version without all the rest that isn't about this function)
Code:
<html>
<head>
<style type="text/css">
#mainwindow
{
background-image: url('smiley.gif');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: 60px 100px;
height: 500px;
width: 500px;
}
</style>
<script language="javascript">
function move(where){
if(where == '1'){
currentY = document.getElementById('mainwindow').style.backgroundPositionY;
newY = parseInt(currentY); /*Added parseInt if by any chance the Y was returning with the suffix px */
newY = newY - 1; /*Setting to new Y value*/
document.getElementById('mainwindow').style.backgroundPositionY = newY; /* Applying new Y value to the background*/
}
}
</script>
</head>
<body>
<img src="smiley.gif" onClick="move('1')">
<div id="mainwindow"></div>
</body>
</html>
Now this does absolutely nothing, and I found very little about getting the backgroundPosition value, only a whole lot about setting it.
So I ask of you, possibilities?, have I done something very stupid ?