onlyican Posted June 17, 2012 Share Posted June 17, 2012 hi all I am rebuilding a site. Basically I have a page which has 2 boxes on the right hand side which fill the screen On Load one big is hidden On click of a P tag, javascript runs, gets the available height (depending on the height of the window), divides by 2, then shows the 2nd div. Then you click an X image on the 2nd div, and that div hides again, then resizes the first div to full height. Works fine FIRST TIME BUT when I click the P tag the 2nd time (after hiding the div) it goes weird Close the div, try third time, works perfect Try fourth time, goes weird again Example link http://help.rideandtag.co.uk/main.php Theres no PHP coding, so all can be seen via source code. TRY it 1) Click "Show listing Demo" on the left hand side. 2) Blue box appears 3) Click the X on the top right of the BLUE box 4) Blue box goes 5) Click Show Listing Demo on left hand side again 6) WTF!!!! 7) Click the X again in the blue box) Repeat from 1 and get same results EDIT:// Console.log has some debug, shows the height being set to 0. Dont know why the maths does not equal 0 Quote Link to comment Share on other sites More sharing options...
RobertP Posted June 18, 2012 Share Posted June 18, 2012 try something like this var isBoxShowen = false; function showMap(){ if(!isBoxShowen){ showBox(); isBoxShowen = true; } } function hideMap(){ isBoxShowen = false; } ps: i recommend using http://api.jquery.com/visible-selector/ Quote Link to comment Share on other sites More sharing options...
onlyican Posted June 19, 2012 Author Share Posted June 19, 2012 Fixed it. For some reason when I set the desc box to visible it was causing a scroll , thus pushing main down to float under sidebar, thus causing offset to be the height of the document. Resulting is height of document minus offset of map (being below doc height) total 0. but by the time the debug spat the code out, it was back to the top, thus showing incorrect figures in the console log (and not showing a scroll bar) Simple fix, set the width to 0 (so the scroll wont force the position below the page) at the start of the function and reset the width at the end Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.