[Javascript] Window dimensions?

Troy III Ajnej trojani2000 at hotmail.com
Sun Jul 16 01:45:20 CDT 2006


Here, if you start with: browser sniffing; syntax: supported/not supported,
values: matched/didn't mach and making other necessary adjustments, -this 
simple demand will require over 100 lines of (getting ugly) script and at least 
a week of debugging!
 
If you are asking for a solution of simply displaying a HTML object in the lower
right corner of the page statically, -but nothing more; all you need, is a little magic converting  
physical dimensions into abstract ones, becoming browser independent.
To do this,
first: you declare your object in this manner:
 
<div id="BRC" 
  style="position:absolute; top:100%; left:100%; width:140px; height:140px; background:navy;">
  some sample text
</DIV>
 
This way you've converted Top and Left measures into abstract values, so every browser will know 
how to convert them into their own current dimensions. Now that we're done with the magic, all we 
have to do is to get this object in place, since we now have both, the height and the width of the Unknown Browser.
 
The script:
var BRC = document.getElementById( "BRC" ) 
BRC.style.top = (BRC.offsetTop - BRC.offsetHeight)
BRC.style.left = (BRC.offsetLeft - BRC.offsetWidth)
 
And tihis is all?
-Of course it's not!  
The following is optional, -depending on the content/layout of the page
 
[add these on top of current script if needed]
var BDY = document.getElementById( "BDY" )
BDY.style.overflow = "hidden"
 
and/or/if also the:
 
BDY.style.overflow="auto"
[At the end of current, only if needed]
 
But as I've already stated, -once you are onto tweaking, you are no longer in charge.
You run into compromise allowing things to get complicated, while code grows rapidly
into noncomprehensive bunch of letters.
 
This much for a free solution, otherwise, a better solution would forever be: sending 
a Null-Dimensional, Pilot-Probe-Object to take and retrieve measures, instead of the real one first!
 
*tested in NN8 (both modes), IE6, Opera9 and  FX1.5
 
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Troy III
progressive art enterprise
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 



> From: john at jwarner.com> To: javascript at LaTech.edu> Date: Sat, 15 Jul 2006 04:41:09 -0400> Subject: [Javascript] Window dimensions?> > Is there a way to determine the internal size (the area where the> document displays) of the browser window. Sort of: > x = window.width >  y=window.height> > I need to place an object in the lower right corner of the users browser> if this helps and I need to get it there no matter what their browser> window size.> > Thanks> > John Warner> > > _______________________________________________> Javascript mailing list> Javascript at LaTech.edu> https://lists.LaTech.edu/mailman/listinfo/javascript
_________________________________________________________________
Try Live.com: where your online world comes together - with news, sports, weather, and much more.
http://www.live.com/getstarted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20060716/6cbcd8a3/attachment.htm>


More information about the Javascript mailing list