f



window.scrollTo to the end of the document?

Greetings again, 
Is there a good way to scroll to the end of a document?

Assuming that document.height doesn't exist in IE, and that
window.scrollTo(x,y) and window.scroll(x,y) would demand
  y = document.height - window.innerHeight;
or something like it, can you use something crude like
  window.scrollBy(0,100000);
or do some browsers just ignore that ?  Is there a better way?

Regards,  Peter

-- 
Peter Billam       www.pjb.com.au    www.pjb.com.au/comp/contact.html
0
Peter
5/6/2009 3:48:30 AM
comp.lang.javascript 38370 articles. 1 followers. javascript4 (1315) is leader. Post Follow

2 Replies
420 Views

Similar Articles

[PageSpeed] 27

Le 5/6/09 5:48 AM, Peter Billam a �crit :
> Greetings again, 
> Is there a good way to scroll to the end of a document?
> 
> Assuming that document.height doesn't exist in IE, and that
> window.scrollTo(x,y) and window.scroll(x,y) would demand
>   y = document.height - window.innerHeight;
> or something like it, can you use something crude like
>   window.scrollBy(0,100000);
> or do some browsers just ignore that ?  Is there a better way?

an anchor at all end of the doc, no ?

<a name="end"></a>
</body>



<a href="#end">hop! to bottom</a>

<a href="javascript:location='#end'">go to end with JS</a>
to be sure that those without JS can't use it ;-)


or if it is not possible to have an anchor :
(not tested)

function go2end() {
var end = document.body.lastChild;
while(end.tagName != 'DIV' || end.tagName != 'P')
end = end.patentNode;
if(!end.id) end.id = 'theEndOrBottom';
location = '#'+end.id;
}

function go2end() {
if(!document.getElementById('theEndOrBottom') {
   var end = document.createElement('A');
   end.id = 'theEndOrBottom';
   document.body.appendChild(end);
   }
location = '#theEndOrBottom';
}

-- 
sm
0
SAM
5/6/2009 7:53:49 AM
Peter Billam wrote:
> Is there a good way to scroll to the end of a document?

Yes, the End key.

> Assuming that document.height doesn't exist in IE,

scrollHeight (also in !MSHTML)

<http://jibbering.com/faq/#posting>


PointedEars
0
Thomas
5/7/2009 6:13:53 AM
Reply: