D
Developer
Anyone know how to figure out how tall a #div is after its rendered by a browser. This way I can display additional ads if there is room.
Anyone know how to figure out how tall a #div is after its rendered by a browser. This way I can display additional ads if there is room.
Developer said:Looks like scrollHeight is what I need, this way I can show ads ad nauseum.
When using Latin phrases, one should know a bit about them: ad nauseam ("to
the point of nausea", "the sensation of unease and discomfort in the stomach
with an urge to vomit." [Wikipedia]).
Anyone know how to figure out how tall a #div is after its rendered by a browser. This way I can display additional ads if there is room.
Thomas Allen said:When using Latin phrases, one should know a bit about them: ad nauseam
("to
the point of nausea", "the sensation of unease and discomfort in the
stomach
with an urge to vomit." [Wikipedia]).
Judging by his homepage's background color, he may indeed mean it
literally.
Thomas
I've been testing (not fully tested yet) this JS code by John Resig's
book.
fullHeigth() will return an element's height even if that
element is not displayed (display: 'none'):
function fullHeight( elem ) {
// If the element is being displayed, then offsetHeight
// should do the trick, barring that, getHeight() will work.
if ( getStyle( elem, 'display' ) != 'none' )
return elem.offsetHeight || getHeight( elem );
// Otherwise, we have to deal with an element with a display
// of none, so we need to reset its CSS properties to get a more
// accurate reading.
var old = resetCSS( elem, {
display: '',
visibility: 'hidden',
position: 'absolute'
OMFG.
});
// Figure out what the full height of the element is, using
clientHeight
// and if that doesn't work, use getHeight
var h = elem.clientHeight || getHeight( elem );
// Finally, restore the CSS properties back to what they were.
restoreCSS( elem, old );
// and return the full height of the element.
return h;
}
function getHeight( elem ) {
// Gets the computed CSS value and parses out a usable number.
return parseInt( getStyle( elem, 'height' ) );
}
function resetCSS( elem, prop ) {
var old = {};
// Go through each of the properties
for ( var i in prop ) {
// Remember the old property value
old[ i ] = elem.style[ i ];
// And set the new value
elem.style[ i ] = prop;
}
// Retun the set of changed values, to be used by restoreCSS
return old;
}
// A function for restoring the side effects of the resetCSS function
function restoreCSS( elem, prop ) {
// Reset all the properties back to their original values
for ( var i in prop )
Again.
elem.style[ i ] = prop[ i ];
}
function getStyle( elem, name ) {
// If the property exists in style[], then it's been set recently
(and is current)
if (elem.style[name])
return elem.style[name];
// Otherwise, try to use IE's method
else if (elem.currentStyle)
return elem.currentStyle[name];
// Or the W3C's method, if it exists
else if (document.defaultView &&
document.defaultView.getComputedStyle) {
// It uses the traditional 'text-align' style of rule writing,
instead of textAlign
name = name.replace(/([A-Z])/g,"-$1");
name = name.toLowerCase();
// Get the style object and get the value of the property(if
it exists)
var s = document.defaultView.getComputedStyle(elem,"");
return s && s.getPropertyValue(name);
// Otherwise, we're using some other browser
} else
return null;
}
Hopefully someone will come up with something better than that.
Which is a completely senseless end-around for poorly designed
applications (or libraries that want to do everything for you.)
What sort of nonsense is that? Regardless of what getHeight does, an
offsetHeight can be 0. Missing brackets, early returns; this looks
like Resig's work.
Why the sudden detour? What do you consider the "full height" to
mean?
So, not even close. Also missing a radix (and you wanted parseFloat
anyway.)
Like it or not, you should RESIGn yourself to the inevitable
facts that RESIG has written a good selling book, he's known worldwide
(YouTube, international conferences), and he was hired by Mozilla
Foundation probably earning a LOT of money. And what about you, David
Mark?
Looks as though you haven't told me anything.
Does the lack of brackets invalidate the code? You're picking apart a
couple minor issues.
This was the only usable part of your long and boring analysis.
Do you really expect heights such as "08px" or "09px". In this
specific case radix is useless and Resig is aware of that. But you are
the Very keen knowledgeable guy.
<bla-bla-bla snipped>
Ok, that was a nice try to debunk the work of John Resig, but your
prototype of response didn't aggregate anything to the OP's problem.
You even sounded like a peeved child crying out loud: "Look Mom, John
Resig has stolen my Teddy Bear!" Indeed your anti-jQuery crusade
really sucks!
I could only understand your "answer" as the cry of a VERY resentful
person.
Like it or not, you should RESIGn yourself to the inevitable
facts that RESIG has written a good selling book, he's known worldwide
(YouTube, international conferences), and he was hired by Mozilla
Foundation probably earning a LOT of money. And what about you, David
Mark?
On Sun, 28 Jun 2009 at 04:25:24, in comp.lang.javascript, JR wrote:
Allen Stanford was also known world-wide and was paid even more money.
I could only understand your "answer" as the cry of a VERY resentful
person. Like it or not, you should RESIGn yourself to the inevitable
facts that RESIG has written a good selling book, he's known worldwide
(YouTube, international conferences), and he was hired by Mozilla
Foundation probably earning a LOT of money.
JR meinte:
Ah a true disciple. John will be proud of you. I'm pretty sure
worshipping Him will make you a good JS coder. One day. Eventually. Or so..
JR meinte:
Ah a true disciple. John will be proud of you. I'm pretty sure
worshipping Him will make you a good JS coder. One day. Eventually. Or so..
</SPAM>Gregor
--http://www.gregorkofler.comhttp://web.gregorkofler.com- vxJS, a JS lib in progress
Um, no, but I see that Mark's cap fits in you too...
I don't give a damn to John Resig and his jQuery. What is annoying is
to be forced to watch all this clownery about jQuery almost everyday,
as though cljs was a circus with 'Dave the Clown' in the centre of the
ring.
As Mark (Dave) and Resig live in the same country, they could spare
our time by duelling and killing each other, thus making a favour to
the rest of the world. But no, Mark doesn't seem to have the courage
to challenge Resig in public. Look at Mark's horrible web 1.0 website
(cinsoft.net)
, and try to find any of the hallucinated posts
condemning both jQuery and their followers. And the man still calls
himself in his 'resume' (www.linkedin.com/in/davidmark) as
"Experienced software designer and programmer, Web developer, IT
manager and consultant. Ten years as a top-level IT executive with
last eight as head of own firm." - What a ridiculous person!
Know what? Mark is just a coward, who knows that the future of his
*business* would be seriously compromised by attacking John Resig and
his zillion supporters using a true website. That's why he lurks in
jQuery group and only barks furiously in a Usenet group (cljs).
I can imagine *all* the Cinsoft staff (maybe a secretary, a security
guard and some trainees?) congratulating their boss in the office by
his brilliant anti-jQuery crusade: "Mr Mark, don't mind if 99.9% of
the world don’t agree with you about jQuery, because, for us, you're
the best developer in the world”. That’s because everyone know the Law
1 – Never Outshines the Master. However, Mark should learn the Law 2 -
Never put too Much Trust in Friends…
What?
Sorry people, but Google, Dell, Bank of America, NBC, CBS,
Technoratti, Mozilla Foundation, Wordpress, Drupal amongst other must
support jQuery for a good reason.
Please let me know if any of the big
companies support "My Library" or "vxJS".
</SPAM>
Like you, I'm just a coder in progress.
You aren't like me.
Sorry people, but Google, Dell, Bank of America, NBC, CBS,
Technoratti, Mozilla Foundation, Wordpress, Drupal amongst other must
support jQuery for a good reason.
Please let me know if any of the big
companies support "My Library" or "vxJS".
Like you, I'm just a coder in progress.
Gregor said:the ones *you* imagine, but I am right.
Guess what - some companies use jQuery *and* vxJS beside each other.
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.