Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Body offsetwidth help

Status
Not open for further replies.

irbk

MIS
Oct 20, 2004
578
US
I'm very new to Java. I have a menu item that is very easy to use to create java menus. The problem is when your trying to create a site that is compatable for many different screen resoluions. The menu created is static. IE it's always left X pix and down Y pix from the upper left hand corner of the screen. This is great if your not worried about creating pages that will be viewed by multiple resolutions. I found the following code off of another site.
"in you're page after the <body> tag you must insert a code like this:
<script language=javascript>
if (document.body.offsetWidth<....){ myLeft = ....;} else {myLeft = ((document.body.offsetWidth-....)/2)+.....;}
</script>
replace ... with correct value for your site."
I need some more help interpreting the script. Basically I want the script above to work for 800x600, 1024x768, and 1280x1024 if possible. Any help you can give would be great. Thanks in advance!
 
Why would the screen resolution matter to you?

Provided that you can see what your design looks like by adjusting your window size or screen resolution to the intended viewport equivalents, I see no reason for your menu program to react any differently under different resolutions if you're always binding to the top left corner, Just make sure you don't bind anything to flow past your minimum size - 800x600 in your case. If that one looks fine, then you can't get any menu problems as the page grows; the menus will always fit.

If you're trying to simulate binding to the top right corner or the use of proportional spacing by calculating sizes and then working from the top left then take a tip and DON'T try. It's a terrible method with which to do that. Use CSS to bind containers to required positions with percentage units if you want proportional spacing, relative to whichever two border edge(s) make sense to use. Then bind the relevant menu(s) to the containers' positions instead of using absolute positioning.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top