The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

XLib - Getting Page Size

I'm trying to popup a login dialog over a page. I want the page to be slightly occluded by a semi-transparent layer.

So I got that to work (huzzah!), but if the user scrolls, the semi-transparent layer (called cloak) only covers part of the page (it's got a top and left of 0 in the CSS), and it only goes down as far as the size of the browser window.

I used X to set the size of the cloak div to that of document.body. That worked in width, but in height it was short by about 70px. Not sure why... This is in FF 2.0.0.3.

I added 70px, and it worked, covering the page to the bottom. If someone can explain why it came up short, I'd appreciate it.

The next item is positioning the dialog box in the current viewport. It may also be desirable to make it travel as the user scrolls. Can someone point me to the right functions in XLib for that?

Not sure what I was using to get the page size. But xDocSize works without adjustments.

Great!

Originally Posted by alfred3x

I'm wondering why I can't seem to position the dialog div using el.style.top. Instead I've used xTop() and it works.

There are a couple of things to be aware of:

1. Kravvitz has pointed out the first thing: the top property has different semantics depending on the value of the position property.

2. Usually this is the real "gotcha". The style object properties correspond to the inline STYLE attribute of the HTML element. This article, tho not very complete, should explain the basic idea. The xTop function gets around this by using getComputedStyle if ele.style.top is an empty string.

2. Usually this is the real "gotcha". The style object properties correspond to the inline STYLE attribute of the HTML element. This article, tho not very complete, should explain the basic idea. The xTop function gets around this by using getComputedStyle if ele.style.top is an empty string.

Right, I remember reading something about this. (d'Oh!)

Thanks to you both!

My current problem (final? ) is with positioning the dialog box (div) within the viewport. I'm using this code:

Ideally, I'd like the dialog box to appear 70px from the top of the viewport.

This is working sometimes (when Firebug is open), but not others (when FB is closed and I'm at the top of the page). Sometimes, it places the dialog box just below the viewport. (!?) The top setting is 70 for that.