Absolutely Positive

It’s becoming increasingly clear (no pun intended) that I need to have some sort of dedicated portion of this website for these little scripts (and larger ones like ShortStat) rather than cluttering up my homepage. Really, how much absolute positioning and JavaScript can one take in a single sitting?

Here it is, revised one last time (although probably not the last time) to eliminate the “double-smack” of v1.5 in IE 5.5+ PC:

SI_clearAbsolutes v1.6 Packaged source. Just unzip, configure the SI_url variable in the JavaScript file, upload to your server and then place the script tag immediately before the closing body tag of any document with absolutes to be cleared. Done.

Thanks to everyone who picked this script apart and provided alternate code to consider.

Previous
MT-Blacklist wins Grand Prize
Next
BBEdit on your PC?
Author
Shaun Inman
Posted
July 23rd, 2004 at 12:46 am
Categories
CSS
JavaScript
Comments
012 (Now closed)

012 Comments

001

How about you keep them in .COM/MISERATE/ or .COM/POST/?

:D

Author
Jason Santa Maria
Posted
Jul 22nd, 2004 9:20 pm
002

Sweet, version 1.6 is nice.

Maybe the all the new stuff goes into .COM/PONENTS and then as the code withers or gets replaced with new code, it moves into the aforementioned .COM/POST heap.

Author
Mike D.
Posted
Jul 22nd, 2004 10:23 pm
003

So … hypothetically of course … let’s assume I wanted to clear just a specific DIV amongst a bunch of clearing and non-clearing absolutely positioned elements. (I’ve got some with negative margins that this seems to break.) How?

Author
Ryan Thrash
Posted
Jul 28th, 2004 5:49 am
004

There’s the rub. The limitations of the current crop of browsers would require that the unique instances be classed and the script be modified to only touch the marked elements.

I could be missing something though.

Note: My solutions aim to work in as many modern browsers as possible, that means that any approach that relies on accessing computed CSS styles is not an option as versions of Safari—including the current 1.2 release—have no way of accessing this information. And I’m not about to neglect my primary browser. I am aware that the next version of Safari will have this ability but I have no intent of neglecting those who (rightly) refuse to pay for an OS upgrade just to update their browser (Bad Apple).

Author
Shaun Inman
Posted
Jul 28th, 2004 6:12 am
005

I frankly can’t get enough Javascript. And every time there’s no absolute positioning posts I cut my arms.

Author
bearskinrug
Posted
Jul 28th, 2004 1:00 pm
006

One way to do it is to presume that this is indeed an extension of HTML/XHTML and provide extra tags to describe the behavior.

This means creating a new DTD and a providing a new DOCTYPE definition, as well as, well, actually inventing the tags.

This is probably the way W3C wants you to handle this type of thing (look at XForms and MathML), but does it really warrant the hassle?

Author
Dimitri Glazkov
Posted
Jul 30th, 2004 9:50 am
007

So you gonna build a: .com/(something witty that starts with com goes here) section of your site?

Author
Khalil Waldropt
Posted
Aug 1st, 2004 8:57 am
008

Just wondering if someone can help me clear the divs on the following web page: . www.victoriahealing.com/index.php

The instructions are real simple, so I don’t think I screwed them up. The footer, for whatever reasons, always appears on the top of the page??? The structure of the document is pretty simple as well.

Author
Rene
Posted
Aug 26th, 2004 5:35 pm
009

does not work in IE6?

Author
pyc
Posted
Sep 16th, 2004 6:53 am
010

…..while it works okay with firefox 0.9 ….

Author
pyc
Posted
Sep 16th, 2004 9:54 am
011

Hmm, that’s weird. I’m pretty sure that worked fine when I originally posted this. The simple example still works. I was able to fix the nested example by adding a border or padding to the positioned divs.

It still looks a little different but that’s because of the way IE PC mishandles margins.

Author
Shaun Inman
Posted
Sep 16th, 2004 4:20 pm
012

Hi,

I’ve tried to use this system to clear the bottom part of my page, where some absolutely positioned elements are hanging out of the containing box. I can’t seem to make it work though. Can someone please tell me what I’m doing wrong?

Cheers.

Author
Seona
Posted
Feb 13th, 2005 6:19 pm