Absolute positioning with IE Explorer bar

J

Jason Carlton

I'm using screen.width to find the visitors screen size, and then
absolutely positioning Google ads based on their width. I'm doing this
so that the ad is the last thing to load on the page, so it doesn't
slow the page down noticeably for the visitor.

This works fine for 95% of my traffic, but when someone has one of the
"Explorer bars" on (those sidebars for Favorites, History, or Feeds),
or less often more my traffic, if they don't have their browser
maximized, then it places the ads in a different location.

Is there a way to tell if this bar is on? I had thought about placing
a DIV tag on the page with a width of 100%, then using Javascript to
measure the width of that tag to determine the screen width instead of
using screen.width, but I'm not positive that this would work
correctly, much less whether it's the best choice.

TIA,

Jason
 
L

Lasse Reichstein Nielsen

Jason Carlton said:
I'm using screen.width to find the visitors screen size, and then
absolutely positioning Google ads based on their width. I'm doing this
so that the ad is the last thing to load on the page, so it doesn't
slow the page down noticeably for the visitor.

As you have found out, the screen size isn't the same as the browser
viewport size. It's the latter that you need in order to place things
on your page.

Also, I wouldn't expect the position of an image to determine the order
of loading resources. More likely it's the location of the image tag
in the HTML stream.
This works fine for 95% of my traffic, but when someone has one of the
"Explorer bars" on (those sidebars for Favorites, History, or Feeds),
or less often more my traffic, if they don't have their browser
maximized, then it places the ads in a different location.

How do you know that it works?
I.e., how do you know that 95% of your users have a maximized browser,
if you don't measure the viewport (which, if you did, you wouldn't need
to ask this question)?
Is there a way to tell if this bar is on?

Hopefully not. It would be a security concern if the browser can see
which other programs you are running.

You can try to detect the size of the viewport, though.
See: http://www.jibbering.com/faq/#getWindowSize
I had thought about placing
a DIV tag on the page with a width of 100%, then using Javascript to
measure the width of that tag to determine the screen width instead of
using screen.width, but I'm not positive that this would work
correctly, much less whether it's the best choice.

Read the FAQ entry. It's not trivial to get exact numbers, but it'll
probablt work better than trying to reinvent it :)

/L
 
T

Thomas 'PointedEars' Lahn

Jason said:
I'm using screen.width to find the visitors screen size, and then
absolutely positioning Google ads based on their width. I'm doing this
so that the ad is the last thing to load on the page, so it doesn't
slow the page down noticeably for the visitor.

ISTM that you are mistaken.

For if you mean by "absolutely positioning" that you use CSS to position an
element, then be aware that its position has absolutely no bearing on the
load order. First the markup is parsed into tokens, then the resulting
element(s) is/are rendered.

But if you instead mean that you move the element to the bottom of the
document (i.e., the BODY element) by e.g. appendChild(), then it should be
obvious that you cannot do that before the last child node of the BODY
element has been parsed, after which it is far too late to attempt any
optimization as everything has already been parsed and, considering
incremental rendering, rendered. That is, unless you generate the whole
document with scripting, which you really should not do.
This works fine for 95% of my traffic, [...]

That is very unlikely.


PointedEars
 
J

Jason Carlton

Thanks to Lasse, above. That was exactly what I was looking for! :)

For if you mean by "absolutely positioning" that you use CSS to position an
element, then be aware that its position has absolutely no bearing on the
load order.  First the markup is parsed into tokens, then the resulting
element(s) is/are rendered.

No, I mean that I placed the element at the bottom of the page, and
then used absolute positioning to put it where I want it. This works
perfectly when I have the ad on the left side because, otherwise, the
ad would have to load before the rest of the page continues.

This works fine for 95% of my traffic, [...]

That is very unlikely.

Unlikely doesn't mean impossible :) In this case, it's definite.
 
T

Thomas 'PointedEars' Lahn

Jason said:
Thanks to Lasse, above.

"Above"? You don't know what Usenet is, do you?
That was exactly what I was looking for! :)

A pity that you are replying to the wrong posting then.
No, I mean that I placed the element at the bottom of the page,

There is no page, and "bottom" is ambiguous with regard to "page". If
you meant it is the last child element of the BODY element of your HTML
document, you should have said so. If you do not mean that, you are
mistaken after all.
and then used absolute positioning to put it where I want it. This works
perfectly when I have the ad on the left side because, otherwise, the
ad would have to load before the rest of the page continues.

Your original statement was ambiguous enough to be misunderstood:

| [...] and then absolutely positioning Google ads based on their width.
| I'm doing this so that the ad is the last thing to load on the page,
| so it doesn't slow the page down noticeably for the visitor.

The "so" implies that "absolute positioning" is the means with which you
attempt to achieve it to be "the last thing to load". That was debated, as
"absolute positioning" is usually understood as accomplished with style
sheets.

Regardless, you should be aware that the position computed with scripting
is not supposed to take effect until the document was completely loaded.
Unless of course, the element is statically hidden until then, which you
probably do not want either, or you assume unwisely that an element object
is available directly after the corresponding element has been parsed.
This works fine for 95% of my traffic, [...]
That is very unlikely.

Unlikely doesn't mean impossible :) In this case, it's definite.

You don't know what you are talking about.


PointedEars
 
D

David Mark

As you have found out, the screen size isn't the same as the browser
viewport size. It's the latter that you need in order to place things
on your page.

Also, I wouldn't expect the position of an image to determine the order
of loading resources. More likely it's the location of the image tag
in the HTML stream.

For sure.
How do you know that it works?
I.e., how do you know that 95% of your users have a maximized browser,
if you don't measure the viewport (which, if you did, you wouldn't need
to ask this question)?


Hopefully not. It would be a security concern if the browser can see
which other programs you are running.

You can try to detect the size of the viewport, though.
See:http://www.jibbering.com/faq/#getWindowSize
Don't.


Read the FAQ entry. It's not trivial to get exact numbers, but it'll
probablt work better than trying to reinvent it :)

It is trivial to get exact numbers and there was never a need to re-
invent it (which is what the FAQ entry tried to do). ;)

http://www.cinsoft.net/viewport.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top