tags:

views:

308

answers:

2

Am curious to know how you create a frozen/non-scrolling regions on a webpage using javascript! like the one used by Stackoverflow when they alert you of the badge you have earned with a "X" close button!

Gath

+3  A: 

You don't need to use javascript, you can do it with CSS just by setting the CSS property "display" to "fixed". You can of course do this with javascript if you like, like so:

var element = ...code to get the element you want...;
element.style.display = 'fixed';
John
+2  A: 

That's using CSS's position: fixed

body {
    margin-top: 20px;
}

#banner {
    position: fixed;
    height: 20px;
}
alex
This is not "position: static" -- "position: static" is the default positioning for most elements. This is "position: fixed".
John
Yes I know... my brain didn't work in my haste. I have ammended.
alex