suzie Posted April 30, 2010 Share Posted April 30, 2010 Dear Friends,I have a div, and under this Div I want to place a footer, and the Div height differ from article to article...so am using this JS function to get the Height of a DIV:<script language="javascript" type="text/javascript"> function getDivHeight() { height = document.getElementById("body-internal-sub").offsetHeight; } </script>from PHP, I called the functionecho "<script> getDivHeight();</script>";till now everything goes wellbut How can I access the "height" (JS variable) in PHP to do my "If ELSE Statement"..any Help please Link to comment Share on other sites More sharing options...
ShadowMage Posted April 30, 2010 Share Posted April 30, 2010 PHP and JavaScript are two entirely different things. PHP is run on the server first, and JavaScript runs on the client second. That means that any JavaScript you have in your page is just plain text when it's in still in PHP on the server. Which means that the two cannot communicate (except through the use of AJAX, but that won't help you with your situation ). PHP also has no knowledge of how big or small any elements will be or what they will look like or anything.You might be able to find a CSS solution to your problem if you Google 'sticky footers' Link to comment Share on other sites More sharing options...
killboy Posted May 2, 2010 Share Posted May 2, 2010 Could you give me an example of what your If...Else statement would be like? Link to comment Share on other sites More sharing options...
suzie Posted May 4, 2010 Author Share Posted May 4, 2010 thanks for your reply Killboy,my if else statement would be like,for example if Height < 800 {to put this inline after the frame}else{put another inline}to know how much I need space to locate the footerthank a lot Link to comment Share on other sites More sharing options...
ShadowMage Posted May 4, 2010 Share Posted May 4, 2010 You can't do that with PHP. You could maybe work something out with JavaScript in the onload event where you calculate the height of the div and then move your footer accordingly.Besides what you describe sounds like the normal flow of elements. If you have a div containing an article then just code in another div for your footer after it the footer will always be at the bottom of the article. <div id='article'> <p>Article text in here. No matter how much text you put in here the footer div below will always be right after this div when its displayed.</p></div><div id='footer'> <span>Footer text</span></div> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.