Some help with scrollTo please?

J

junk419

Hi all. First of all I know pretty much nothing about Javascript :)
It's just that I found a program/script that will refresh a webpage
(not mine) every so often. It's called AllStock's AutoRefresh. What I
am hoping some can help me with is for when it refreshes I would like
for it to scroll down about 3 or 4 clicks OR I can scroll it down my
self but when it refreshes it goes down to the point I was at. Either
is really fine with me. Here's what I have in the refresh.htm code:

var cycle=1;
sites=["http://www.thesite.com"];
sites_upper=1;
delay=.5*60000;
function
reload_page(){parent.frames[0].location=sites[cycle];if(cycle==sites_upper)cycle=0;else
++cycle;}</SCRIPT><body
onLoad="parent.frames[0].location=sites[0];window.setInterval('reload_page()',delay)"></body></html>

This is what is in the index.htm code in case you'd need to look at
that too:

<html><frameset rows=*,0 border=0 frameborder=0 framespacing=0><frame
name="clientarea" border=no framespacing=0 noresize><frame
src="refresh.htm" name="refresher" border=no framespacing=0
noresize></frameset></html>


Thanks in advance for any help you might be able to give me!
 
T

taoberly

It's almost certainly not universal, but I think you want to read
window.pageXOffset and window.pageXOffset. (At least
Netscape-compatible browsers will support this.) So as the first line
of the reload_page() function, I would add

x = window.pageXOffset;
y = window.pageYOffset;

and then as the last line, add

window.scrollTo(x,y);

Something like that. Without seeing it in action, this may not be 100%
correct, but it's close.

Good luck,

Todd
 
J

junk419

Well, like I said above, I am not at all familiar with javascript and
how it all goes etc. I'd really appreciate it if someone could show me
exactly where it goes. I've tried looking up examples but everyone's
seems to be a little different. Also do I need to substitute x & y
with numbers and if so which ones?

Thanks!
 
J

junk419

Well, like I said above, I am not at all familiar with javascript and
how it all goes etc. I'd really appreciate it if someone could show me
exactly where it goes. I've tried looking up examples but everyone's
seems to be a little different. Also do I need to substitute x & y
with numbers and if so which ones?

Thanks!
 
E

Evertjan.

wrote on 27 apr 2006 in comp.lang.javascript:
Well, like I said above, [..]

"Above"? As you so comprehensively demonstrate
by writing this on the first line of your posting:

please do not toppost on usenet.

===============

[topposting corrected]
Well, like I said above, I am not at all familiar with javascript and
how it all goes etc. I'd really appreciate it if someone could show me
exactly where it goes. I've tried looking up examples but everyone's
seems to be a little different. Also do I need to substitute x & y
with numbers and if so which ones?

The x and y variables must be filled with the values of your scroll
destination.

So if you want to record the present position for a LATER(!) vertical
scroll:

x = 0;
y = window.pageYOffset;

will do that for you on some browsers.

window.scrollTo(x,y);

called by user or timer action,
will do the actual scrolling,
when you want to get BACK(!!!) to that previous recorded position.

=================

Programming such scrolling is IMHO not for the beginning js programmer,
better first do some simple projects to learn,
.... or source it out as a payed project, if it is worth it.
 
T

taoberly

(e-mail address removed) wrote:
Well, like I said above, I am not at all familiar with javascript and
how it all goes etc. I'd really appreciate it if someone could show me
exactly where it goes. I've tried looking up examples but everyone's
seems to be a little different. Also do I need to substitute x & y
with numbers and if so which ones?

If you're still confused, email me the code privately. It's a simple
thing, but I can't say something will work 100% unless I try it myself.

Todd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top