...

View Full Version : Prevent page from scrolling (only temporarily)



NancyJ
06-08-2008, 01:08 PM
I need to stop the page from scrolling when using the up and down keys, but only temporarily.

I want the user to be able to focus on a list and then use the up and down keys to scroll through the items in the list (basically like a select box but with a ul instead) but without the page scrolling as well.

effpeetee
06-08-2008, 02:52 PM
Is this any help. (http://msdn.microsoft.com/en-us/library/bb189730.aspx)

Frank:D

NancyJ
06-08-2008, 05:40 PM
uh... not even close.

I don't mean to sound rude or ungrateful but did you even read it?

effpeetee
06-08-2008, 07:34 PM
uh... not even close.

I don't mean to sound rude or ungrateful but did you even read it?
No! of course not.
Why would I bother to read it?

BabyJack
06-08-2008, 07:53 PM
scroll="no" <-- Place that in your body part of CSS

NancyJ
06-08-2008, 08:54 PM
scroll="no" <-- Place that in your body part of CSS

again, not even close to what I'm looking for.

NancyJ
06-08-2008, 08:56 PM
No! of course not.
Why would I bother to read it?

To find out if its even vaguely in the area of what the question was about? It was an article on scrollers in Windows Media Center Markup Language O.o

oesxyl
06-08-2008, 11:47 PM
inspired by BabyJack, :) overflow: hidden, :)
more detailed:
- set overflow: hidden
- attach a onkeydown, onkeyup or if I'm not wrong a onkeypress, to manage the keycode for up and down keys and box scroll

I don't have any idea how to trigger the reverse process when the user finish, maybe a onblur, but onblur what?

why you can't use a listbox instead of all this?

regards

NancyJ
06-09-2008, 08:28 AM
Overflow:hidden still allows you to scroll up and down with the up and down keys.


why you can't use a listbox instead of all this?

That would defeat the point ;) But more specifically because they can't be styled properly.

I've found a way around the problem by leaving the focus on the text box. In firefox I can set the field to readonly so that prevents users from typing in the text box (and gets rid of the text cursor) but it still captures the key input but in ie, setting it to readonly moves the scroll bar up and down again. Ideally I need something that prevents users typing in the text box and gets rid of text cursor but while still retaining focus on the text box.

BabyJack
06-09-2008, 04:15 PM
No offence, but your question makes no sence. Adding <body scroll="no"> disables scrolling then delete it temporarily! =]

NancyJ
06-09-2008, 05:23 PM
No offence, but your question makes no sence. Adding <body scroll="no"> disables scrolling then delete it temporarily! =]

body scroll="no" only works in IE - its something microsoft made up and it removes the scroll bars which I don't want to do.
My question makes perfect sense, I want to temporarily prevent the up and down arrows from scrolling the window.

oesxyl
06-09-2008, 05:28 PM
No offence, but your question makes no sence. Adding <body scroll="no"> disables scrolling then delete it temporarily! =]
no offence ut there is no scroll atrribute, :)


Overflow:hidden still allows you to scroll up and down with the up and down keys.
yes, it just make the scrollbar invisible.


That would defeat the point ;) But more specifically because they can't be styled properly.
for me is less painfull to style it, :)

regards

Mr J
06-09-2008, 08:44 PM
Give this a try



<script type="text/javascript">

function getKey(e) {
keycode=(!e?event.keyCode:e.which)
if(keycode==38||keycode==40){
return false
}
}

document.onkeydown = getKey

</script>


Sorry mines no good either

Mr J
06-09-2008, 09:12 PM
Here's what I've been toying with so far.

Click on "ONE" then use the up/down arrow keys



<script type="text/javascript">

count=0

function getKey(e) {
keycode=(!e?event.keyCode:e.which)

if(keycode==38){count--} // up
if(keycode==40){count++} // down

if(count==document.getElementById("myul").getElementsByTagName("A").length){
count=0
}

if(count<0){count=document.getElementById("myul").getElementsByTagName("A").length-1}

document.getElementById("myul").getElementsByTagName("A")[count].focus()

return false

}

document.onkeydown = getKey

</script>


<ul id="myul">

<li><a href="#null" onclick="count=0">one</a>
<li><a href="#null" onclick="count=1">two</a>
<li><a href="#null" onclick="count=2">three</a>
<li><a href="#null" onclick="count=3">four</a>

</ul>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum