Jump to content

[SOLVED] VERY SIMPLE - Moving a "Absolutely" positioned div.


d22552000

Recommended Posts

statica.style.top=currentpos+"px"
statica.style.left=5+"px"

 

When I put that in my script, it f***s up and says it expects an object at the "s" in "statica.style.top"..

 

..

 

My full script is here:

<script type="text/javascript" language="JavaScript1.2"> 

var speed=50
var currentpos=0
var statica=document.getElementById("asvesee");

function scrollwindow(){
if (document.all)
currentpos=document.body.scrollTop+speed
else
currentpos=window.pageYOffset+speed

window.scroll(0,currentpos)

// I am trying to put statica movement HERE.
}

function startit(){
setInterval("scrollwindow()",50)
}
</script>

<div id="asvesee" style="position:absolute; border:1px solid black; background-color: lightyellow; width: 425px;">
<a href="javascript:startit()">Auto-Scroll Progress</a><br />
Remember, you can close this page, and the upload will continue!<br />
Please email [email protected] with bugs and feedback.
</div>

 

This is a VERY simple script to auto-scroll the window, and doesn't quite work on all browsers, but I suck at javascript (as you can tell by my simple question) Please tell me why it won't work, and how to fix it.

 

BTW: This error comes up in IE7.

try this:

 

<script language="javascript"> 

var speed=50
var currentpos=0
var statica=document.getElementById("asvesee");

function scrollwindow(){
if (document.all) {
currentpos = document.body.scrollTop + speed;
}
else {
currentpos = window.pageYOffset + speed;
}

window.scroll(0,currentpos);

// I am trying to put statica movement HERE.
statica.style.top = currentpos +"px";
statica.style.left="5px";
}

function startit(){
setInterval("scrollwindow()",50)
}
</script>

<div id="asvesee" style="position:absolute; border:1px solid black; background-color: lightyellow; width: 425px;">
<a href="javascript:startit()">Auto-Scroll Progress</a><br />
Remember, you can close this page, and the upload will continue!<br />
Please email [email protected] with bugs and feedback.
</div>

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

 

Note: I did not test the above code in IE7; but it works fine in FF and IE6.

try this:

 

<script language="javascript"> 

var speed=50
var currentpos=0
var statica=document.getElementById("asvesee");

function scrollwindow(){
if (document.all) {
currentpos = document.body.scrollTop + speed;
}
else {
currentpos = window.pageYOffset + speed;
}

window.scroll(0,currentpos);

// I am trying to put statica movement HERE.
document.getElementById("asvesee").style.top = currentpos +"px";
document.getElementById("asvesee").style.left="5px";
}

function startit(){
setInterval("scrollwindow()",50)
}
</script>

<div id="asvesee" style="position:absolute; border:1px solid black; background-color: lightyellow; width: 425px;">
<a href="javascript:startit()">Auto-Scroll Progress</a><br />
Remember, you can close this page, and the upload will continue!<br />
Please email [email protected] with bugs and feedback.
</div>

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.