2012-04-13 03:50
浏览 36


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?

图片转代码服务由CSDN问答提供 功能建议

我很难设置左列的适当高度和页脚的位置,相对于内容的位置 中心列(由Ajax填充)。

我的代码 适用于纯客户端布局,但它没有检测到 Ajax对高度所做的任何更改(服务器端和所有)。 那么我怎样才能获得页面的高度,包括 Ajax所做的更改?

我想我可能需要设置一个JavaScript变量来自我的 确定Ajax高度的PHP文件......或者可能确定是否触发了Ajax事件...


  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • douwen1213 2012-04-13 03:54

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

    解决 无用
    打赏 举报
  • douchenhui5569 2012-04-13 04:38

    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.

    解决 无用
    打赏 举报
  • duanhuiqing9528 2012-04-13 07:13

    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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题