Agtronic Posted January 13, 2008 Share Posted January 13, 2008 Hi guys, I don't know where to even begin to search for this. I've been messing with this for a long time now, and I'm getting frustrated. I would love if someone could take a crack at it! Basically, I have a few "chefs" on a page, and each of them has a bio. Every bio is different, and contains a different amount of characters. When a user clicks on "view chef", a popup window shows up with the biography etc ... The window is small, (290px wide, by ~500 high. Thing is, I want to be able to calculate how many pixels I need in height, so that the window is not too long or too short. I've been messing with formulas based on strlen() of the bio, but I haven't been able to get anything consistent, or precise, and the page is usually only right for one of the bios, while all the rest end up being too short or too long. I suck at math, big time, so this is really frustrating for me. I'd appreciate any one's help! Thanks! btw : I've come up with two sets of constants. I think I'm going about it the wrong way, but maybe it can help. When the char length of the bio is 916, I need a window of ~730 px high. When the bio is 450 chars long, I need ~570. So, in my weak efforts of trying to visualize the graph in my head, I see the lines crossing. Sorry, I must sound like an acid head with that this last paragraph. Thanks again!! Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/ Share on other sites More sharing options...
twostars Posted January 13, 2008 Share Posted January 13, 2008 Hi guys, I don't know where to even begin to search for this. I've been messing with this for a long time now, and I'm getting frustrated. I would love if someone could take a crack at it! Basically, I have a few "chefs" on a page, and each of them has a bio. Every bio is different, and contains a different amount of characters. When a user clicks on "view chef", a popup window shows up with the biography etc ... The window is small, (290px wide, by ~500 high. Thing is, I want to be able to calculate how many pixels I need in height, so that the window is not too long or too short. I've been messing with formulas based on strlen() of the bio, but I haven't been able to get anything consistent, or precise, and the page is usually only right for one of the bios, while all the rest end up being too short or too long. I suck at math, big time, so this is really frustrating for me. I'd appreciate any one's help! Thanks! btw : I've come up with two sets of constants. I think I'm going about it the wrong way, but maybe it can help. When the char length of the bio is 916, I need a window of ~730 px high. When the bio is 450 chars long, I need ~570. So, in my weak efforts of trying to visualize the graph in my head, I see the lines crossing. Sorry, I must sound like an acid head with that this last paragraph. Thanks again!! Why don't you just let the popup window use a vertical scrollbar? Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/#findComment-437826 Share on other sites More sharing options...
phpQuestioner Posted January 13, 2008 Share Posted January 13, 2008 You know you could just give your pop-up window a scrollbar; set the window pop-up to a specific height and let it overflow as needed. <?php $count = strlen($database_variable_here); if ($count >= "916") { $setHeight="730"; } else if (($count == "450") && ($count < "916")) { $setHeight="570"; } else { $setHeight="500"; } ?> <script language="javascript"> function popIt() { window.open('http://www.google.com','pu','width=290,height=<?php echo "$setHeight"; ?>'); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/#findComment-437829 Share on other sites More sharing options...
Agtronic Posted January 13, 2008 Author Share Posted January 13, 2008 Thanks for your replies. Thing with the scrollbars is that I find them to be quite intrusive to the style of the site. It's important for the site to keep a sleek look. I'm thinking I might just CSS style the bars, and hope for the best. The other thing that really bothers me about the scrollbars, is that as soon the page calls for scrolling, the stupid horizontal one shows up too, and that bothers me immensly. Perhaps I'll make the window wider, in hopes that the horizontal one doesn't show up. Thanks for you time guys! Much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/#findComment-438059 Share on other sites More sharing options...
maexus Posted January 13, 2008 Share Posted January 13, 2008 Sleek style, maybe. The most important things to keep in mind is usability and accessability. Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/#findComment-438069 Share on other sites More sharing options...
Fyorl Posted January 13, 2008 Share Posted January 13, 2008 One option would be to create a 'fake' popup window. E.g. Use a combination of HTML and Javascript to make a floating div containing the chef's info etc. The advantage of this is you can use normal CSS to size the 'window' to fit the text perfectly. Also, styling scrollbars is a bad idea as that CSS only works in IE and so everyone who uses a different browser won't see them. Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/#findComment-438075 Share on other sites More sharing options...
nikefido Posted January 13, 2008 Share Posted January 13, 2008 CSS styles for scroll bars is extremely browser-specific - better google the subject first! Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/#findComment-438076 Share on other sites More sharing options...
Agtronic Posted January 13, 2008 Author Share Posted January 13, 2008 Sleek style, maybe. The most important things to keep in mind is usability and accessability. I agree 100%, which is why it's important for me to make sure all the info shows up in the window, instead of making the users have to scroll down. There has to be a way to come up with a height, based on the amount of data contained in the string. I suck at stuff like this! Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/#findComment-438112 Share on other sites More sharing options...
nikefido Posted January 13, 2008 Share Posted January 13, 2008 Sleek style, maybe. The most important things to keep in mind is usability and accessability. I agree 100%, which is why it's important for me to make sure all the info shows up in the window, instead of making the users have to scroll down. There has to be a way to come up with a height, based on the amount of data contained in the string. I suck at stuff like this! Thanks guys! that would be very hard (read:impractical) because changing CSS rules will change the size of text and what not within your document. Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/#findComment-438148 Share on other sites More sharing options...
Fyorl Posted January 13, 2008 Share Posted January 13, 2008 The fake popup window idea I proposed would allow you to create 'windows' which would automatically resize to fit the content. Quote Link to comment https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/#findComment-438156 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.