Jump to content

Recommended Posts

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!!

Link to comment
https://forums.phpfreaks.com/topic/85784-calculating-size-of-a-popup-window/
Share on other sites

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?

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>

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!

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.

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!

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.