Kamala Harris - Property in Brazil - Investment Articles Directory - Debt Consolidation - Myspace Layouts

PDA

View Full Version : need a bit of code. Interesting idea


Notting
Dec 7th 2006, 5:59 am
Hi guys!

Im looking for a bit of code that will:

when people scroll down the page, bring the page straight back to the top. Ie, people can try to scroll down but cant.

Any ideas?

Notting

The_FoX
Dec 7th 2006, 6:17 am
this can be done if they click on a link(that has to be fixed somewhere) that link should point to an anchor point at the top of the page.

but i dunno how it can be done without clicking. hope this interests you.

heinlein99
Dec 7th 2006, 6:43 am
So if they hold the scrollbar down they can see stuff down the page, but if they let go, it snaps them back up to the top?

I guess I can see some value in that. Sneaky.

Notting
Dec 7th 2006, 8:58 am
You hit the nail right on the head heinlein99!

Anyone got any suggestions for this one?
Notting

smallbuzz
Dec 7th 2006, 10:22 am
Sounds like a really annoying "feature" though, why do you want to do this?

rgchris
Dec 7th 2006, 10:35 am
IMHO it will just drive people away from your site. I know that I'd personally hate it.

the_pm
Dec 7th 2006, 11:20 am
Not that I'm condoning this type of behavior, but the following script will do the trick (I can't think of any way to do this other than JavaScript, which can be disabled).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function jump() {
window.location = "#top";
}
document.onmousemove = jump;
</script>
</head>

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

<!-- All your content goes after the <a name> tag -->

</body>
</html>The script itself and the <a name="top"></a> parts are the only important pieces.

Notting
Dec 7th 2006, 11:44 am
Thanks - rep left
Notting

the_pm
Dec 7th 2006, 11:55 am
Thanks Notting :)

Glad to help.

krakjoe
Dec 11th 2006, 6:07 am
I gotta say I wouldn't be staying too long as a visitor on a site with that sorta thing going on, think about that....

Most ppl will just think this page is broken and never come back.....

Notting
Dec 11th 2006, 8:51 am
thats fine, i hope they leave really quickly!

ajsa52
Dec 11th 2006, 11:51 am
<script type="text/javascript">
function jump() {
window.location = "#top";
}
document.onmousemove = jump;
</script>



This trick not always work: you can scroll down the page with the "down" key (without moving mouse of course).
A better trick is using a timer that several times a second executes function jump().
And instead of window.location = "#top"; you can use
window.scroll(0,0); or wherever position you want.

Using window.scroll(x,y) with different values for x and y each time your visitor will go crazy ;)