|
-
Jan 9th, 2002, 08:46 AM
#1
Thread Starter
Fanatic Member
Where am I on the page?
Some of the pages on my site are dynamically generated and may be quite long.
It occurred to me that if I put something similar to below on the bottom of my page I could check whether the page extended below the bottom of the Client's screen and provide a link to the top if it did.
VB Code:
<P id=BenchMark name=BenchMark></P>
<SCRIPT LANGUAGE=javascript>
<!--
if (window.BenchMark.style.top>screen.availHeight)
{window.document.write("<A href='javascript: void(0)' onclick='return window.scrollTo(0,0)'>Go To Top</A>")}
//-->
</SCRIPT>
Unfortunately however window.BenchMark.style.top just returns a blank string.
Can anyone else think of a way of doing this client side?
-
Jan 9th, 2002, 10:26 AM
#2
Thread Starter
Fanatic Member
OK I have now given up on the above idea and am using this instead.
VB Code:
<SCRIPT LANGUAGE=javascript>
<!--
var oApp = navigator.appName;
var ie = (oApp.indexOf("Microsoft")!=-1);
if (ie){
if (document.body.scrollHeight>screen.availHeight)
{window.document.write("<A href='javascript: void(0)' onclick='return window.scrollTo(0,0)'>Go To Top</A>")}
}
else{
if (window.document.body.offsetHeight>screen.availHeight)
{window.document.write("<A href='javascript: void(0)' onclick='return window.scrollTo(0,0)'>Go To Top</A>")}
}
</SCRIPT>
Unfortunately it doesn't work on Netscape 4 any ideas?
-
Jan 9th, 2002, 10:26 AM
#3
Frenzied Member
*shudder* I give up. Can someone give me a JavaScript manual. I really need to know why people write pages like this.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jan 9th, 2002, 10:43 AM
#4
try what is in bold
VB Code:
<SCRIPT LANGUAGE=javascript>
<!--
var oApp = navigator.appName;
var ie = (oApp.indexOf("Microsoft")!=-1);
if (ie){
if (document.body.scrollHeight>screen.availHeight)
{window.document.write("<A href='javascript: void(0)' onclick='return window.scrollTo(0,0)'>Go To Top</A>")}
}
else{
if (window.document.body.offsetHeight>screen.availHeight)
{window.document.[b]writeln[/b]("<A href='javascript: void(0)' onclick='return window.scrollTo(0,0)'>Go To Top</A>")}
}
</SCRIPT>
-
Jan 9th, 2002, 10:47 AM
#5
Frenzied Member
Uhm, the page may be severly broken, Scoutt, but that isn't it. document.writeln() appends a newline where document.write() doesn't. Since new lines do not matter....
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jan 9th, 2002, 11:11 AM
#6
Thread Starter
Fanatic Member
Hmm, it appears from http://developer.irt.org/script/1400.htm that I would need to stick it all into a layer which isn't really suitable for me so looks like NS 4.0 users are just going to have to scroll to the top manually.
Scoutt thank you very much for your help.
CiberTHuG - What possible objection can you have to people displaying a Scroll to Top hyperlink when the page is longer than the screen?
Is it the principle or do you think my solution is badly coded?
If the latter please put up or shut up!
-
Jan 9th, 2002, 11:24 AM
#7
Frenzied Member
Putting up:
ECMA-262
getElementById()
document is not part of window
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jan 9th, 2002, 11:49 AM
#8
Thread Starter
Fanatic Member
You're right of course but I am not getting any problems with Level 1 DOM browsers.
My problem is with netscape 4.0 which as far as I know has never heard of getElementById()
-
Jan 9th, 2002, 11:55 AM
#9
Frenzied Member
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jan 9th, 2002, 09:10 PM
#10
Sorry I wasn't much of help. I pretty much guessed at that. it looked good though. 
I haven't studied javascript or even worite my own. so I am not that versed in it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|