Ian Campbell
Ian Campbell

Reputation: 2748

How can I find the page height AFTER Ajax extends the content beyond the screen?

I am having difficulty setting the appropriate height of a left column and the positioning of a footer, relative to the content in the center column (populated by Ajax).

My code is working for purely client-side layouts, but it is not detecting any changes made to the height by Ajax (being server-side and all). So how might I get the height of the page, including the changes made by Ajax?

I'm thinking I may need to set a JavaScript variable from my PHP file that determines the Ajax height... or maybe it would be useful to determine if an Ajax event was triggered or not...

Any ideas, common solutions?

Upvotes: 0

Views: 324

Answers (3)

d4rkpr1nc3
d4rkpr1nc3

Reputation: 1827

You don't need javascript to do that, it can be easily done using css tricks. Here's a link for it: http://css-tricks.com/snippets/css/sticky-footer/ Howeever if you really need JS for that, use

document.getElementById("footer").style.top = window.outerHeight + "px";

right after you load content from the http request. I, for one, suggest the css approach.

Upvotes: 0

Erik  Reppen
Erik Reppen

Reputation: 4645

Ajax is not server side. It's an HTTP request initiated from JavaScript and a JS event handler that responds to what the server sends back. You could fire your height checking code after the ajax request initiates and it wouldn't do you any good because the JS fires right away and it takes a least a fraction of a second for that round trip to the server. You have to know enough about what's going on to figure out where the function handling the successful ajax request is and then where in that function HTML is being injected and then follow up with your height-checking/setting code.

Upvotes: 0

sethcall
sethcall

Reputation: 2907

Add javascript code to the page that runs after the AJAX code is executed to determine the height. Use jquery liberally throughout.

Upvotes: 2

Related Questions