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 damon.underground@gmail.com 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.

Link to comment
Share on other sites

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 damon.underground@gmail.com 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.

Link to comment
Share on other sites

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 damon.underground@gmail.com 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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.