better solution for window.scrollTo(x,y), onload is too slow. |
Author: |
Message: |
.Roy
Veteran Member
Posts: 1526 Reputation: 11
20 / / –
Joined: Aug 2004
|
O.P. better solution for window.scrollTo(x,y), onload is too slow.
Currently im using:
<body onload='window.scrollTo(6,112)'>
but onload only activates when the whole page is loaded which might take a long time since the page has a lot of content.
how do i make the window.scrollto happen as soon as that part of the code is loaded?
|
|
09-14-2008 06:55 AM |
|
|
NanaFreak
Scripting Contest Winner
Posts: 1476 Reputation: 53
32 / /
Joined: Jul 2006
|
RE: better solution for window.scrollTo(x,y), onload is too slow.
you could always put it in <script> at the end of the page... but other than that you would have to wait until the whole page has loaded unless you know that 6,112 has loaded and is able to scroll there...
|
|
09-14-2008 07:17 AM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: better solution for window.scrollTo(x,y), onload is too slow.
Remove other content from page. Scroll to 6,112. Load other content using js/ajax?
Get what I mean?
|
|
09-14-2008 07:40 AM |
|
|
segosa
Community's Choice
Posts: 1407 Reputation: 92
Joined: Feb 2003
|
RE: better solution for window.scrollTo(x,y), onload is too slow.
put <script type="text/javascript">window.scrollTo(6,112);</script> into the HTML at the place that you know is approximately the location of (6, 112).
This post was edited on 09-14-2008 at 10:47 AM by segosa.
The previous sentence is false. The following sentence is true.
|
|
09-14-2008 10:46 AM |
|
|
Nathan
Veteran Member
Yeah, "large dimensions" ;)
Posts: 2984 Reputation: 76
– / /
Joined: Apr 2005
|
RE: better solution for window.scrollTo(x,y), onload is too slow.
Use jquery, and there is the document.ready function, which executes whatever is in it as soon as the headers are requested.
|
|
09-14-2008 11:41 AM |
|
|
segosa
Community's Choice
Posts: 1407 Reputation: 92
Joined: Feb 2003
|
RE: RE: better solution for window.scrollTo(x,y), onload is too slow.
quote: Originally posted by Nathan
Use jquery, and there is the document.ready function, which executes whatever is in it as soon as the headers are requested.
It executes on DOMContentLoaded i.e., when the page's source code has been downloaded and the DOM can be manipulated - meaning images may not be loaded yet.
As far as I'm aware window.onload and co only execute once images have been loaded too.
http://docs.jquery.com/Events/ready
Edit: oh, and it's $.ready.
This post was edited on 09-14-2008 at 11:48 AM by segosa.
The previous sentence is false. The following sentence is true.
|
|
09-14-2008 11:47 AM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: better solution for window.scrollTo(x,y), onload is too slow.
quote: Originally posted by segosa
put <script type="text/javascript">window.scrollTo(6,112);</script> into the HTML at the place that you know is approximately the location of (6, 112).
Woah... didn't know this could be done in such a way. I always thought JavaScript was executed after the page loaded itself.
|
|
09-14-2008 11:57 AM |
|
|
.Roy
Veteran Member
Posts: 1526 Reputation: 11
20 / / –
Joined: Aug 2004
|
O.P. RE: better solution for window.scrollTo(x,y), onload is too slow.
what do i do if this page is basically an iframe of another site.
where would i go about putting the <script type="text/javascript">window.scrollTo(6,112);</script>
if the iframe is the only code on the page basically.
|
|
09-14-2008 12:54 PM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: better solution for window.scrollTo(x,y), onload is too slow.
quote: Originally posted by .Roy
if the iframe is the only code on the page basically.
Put the code in page that is the source of the iframe? If you pull that from some other site you don't have access to... get a php script to pull the code, edit it and put the js and then display it.
|
|
09-14-2008 12:56 PM |
|
|
.Roy
Veteran Member
Posts: 1526 Reputation: 11
20 / / –
Joined: Aug 2004
|
O.P. RE: better solution for window.scrollTo(x,y), onload is too slow.
quote: Originally posted by Felu
quote: Originally posted by .Roy
if the iframe is the only code on the page basically.
Put the code in page that is the source of the iframe? If you pull that from some other site you don't have access to... get a php script to pull the code, edit it and put the js and then display it.
yes the code is from an external website and if i pull the code it won't work because whatever i'm trying to get from thier site only works on their site.
(tested by copying source onto html document and it didn't work)
any other solutions?
this is the page btw:
http://www.zomganime.com/mv.php?id=LG0NA8O6
im kind of using 2 iframes to get only the player:
http://www.zomganime.com/code-geass-lelouch-of-th...ion-r2-episode-23/
(look at the bottom video on that page)
but sometimes it takes too long and you can see the megavideo logo so yeah...
This post was edited on 09-14-2008 at 01:04 PM by .Roy.
|
|
09-14-2008 01:02 PM |
|
|
Pages: (3):
« First
[ 1 ]
2
3
»
Last »
|
|