100% Visible Div

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

100% Visible Div

Post by iknownothing »

Hey guys, I have a div that becomes visible upon clicking a link. The page uses vertical scrolling. What I want is a way for the div to pop up approximately 50px from the top of the browser frame, so no matter how far scrolled down you are, it still is completely visible. Does anyone know how this could be achieved?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

	d.style.top = window.pageYOffset + 10 + 'px';
	d.style.left = window.pageXOffset + 10 + 'px';
works in Firefox to give an offset of 10,10 from the corner.
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

cheers for that, any way this can work in IE?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd bet you can find examples with some searching.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

you'll want to use CSS to specify "position:fixed;"
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

thanks Kieran, bit of "standards mode" for IE6 (and IE 7.05730 apparently) and I was happy.
Post Reply