barkster Posted June 11, 2007 Share Posted June 11, 2007 Can anyone tell me how to make a div always show up in the top right corner of the window no matter where they are in the page. I have an error box I would like to display that will be used with some ajax. Thanks Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 11, 2007 Share Posted June 11, 2007 this doesn't work in ie6 or less you can use css.... div#topright { position: fixed; top: 0; right: 0; } or if you don't mind javascript doing it.... immediately after the closing div tag put this code ... </div> <script type="text/javascript"> keepVisible('topright'); </script> (assuming the div you want in the top right has an id of topright!!!! - chnage that accordingly.) then in the head section of the page <script type="text/javascript"> keepVisible = function (id) { var el = document.getElementById(id); var getScrollTop = function() { return document.body.scrollTop||document.documentElement.scrollTop }; el.keepInView = function() { var target = getScrollTop(); var curY = el.offsetTop; var curY = el.offsetTop; var newY = null; target = 0; newY = curY + ((target - curY)/20); newY = Math.ceil(newY); if ( newY == null ) { newY = target; } el.style.top = newY + 'px'; } setInterval('document.getElementById("' + id + '").keepInView()',10); } </script> that will kind of slide it in if you want it to just move immediately then set newy = curY. Quote Link to comment Share on other sites More sharing options...
barkster Posted June 11, 2007 Author Share Posted June 11, 2007 Cool, I'll try that out. I will definately be using the js. What will happen if the user has < 6.0? Thanks Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 11, 2007 Share Posted June 11, 2007 record their ip address and whois them. contact their isp and get their home address. run round and either kill them or tie them up while you update it to ie7 and put ff on there as well. then kill them.... Quote Link to comment Share on other sites More sharing options...
barkster Posted June 12, 2007 Author Share Posted June 12, 2007 Sounds good, I couldn't get it to work but I'd be dead right now if I was around you :-) I found this which worked in all the version I have http://www.javascript-fx.com/submitscripts/float/float.html Thanks Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 12, 2007 Share Posted June 12, 2007 very similar... did you get any errors? (you might find the javscript console for ff useful - its reporting is far better than IE's.) I'm just intrigued as to why it didn't work. Quote Link to comment Share on other sites More sharing options...
barkster Posted June 12, 2007 Author Share Posted June 12, 2007 Where is the javascript console in firefox. I normally use IE script debugger for testing js. I didn't see any errors it just stayed on the left side of screen but I'm using IE6 Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 12, 2007 Share Posted June 12, 2007 its an add on in ff. tools > add ons then click the get extensions link in the bottom right of the popup. search the developer tools for console2 (the 2 is superscript). if you spend a bit of time on those pages you will find other little treasures like the 'web developer' toolbar, css view total validator and so on... have fun. PS is this page live? if you send a link I'll have a look at why the js i sent aint working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.