Join 299,949 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,788 people online right now. Registration is fast and FREE... Join Now!
...Is it possible with Javascript? I have a Coldfusion template page which has on it three buttons that link to three more seperate Coldfusion template pages calling its content from a database. Since the content in these pages varies, my aim is to have the window resize itself to fit the content appropriately and negate having to use the scroll bars. Any help with this will be greatly appreciated.
My problem is that I can't specify the width and height, I need that to be determined by the volume of the content. There are close to one hundred different records of varying size that the user can select. I want to know if Javascript has the capability to look at the record called and adjust the browser size accordingly (dynamically).
I could do that, but it would be a painstaking process, that is why I am looking for a script that can recognize the dimensions and handle the resizing on its own. I'm not even sure its possible due to my inexperience with scripting, hence my journey to dreamincode.net.
In theory, wouldn't then be possible to have a large amount of content that would cause the window to be sized out side of the viewable screen width and length?
To me, I would thing you'd want to size the content with a standard size window that you know the user will be able to view.
What type of content is it? Images? What sizes do you anticipate?
I could do that, but it would be a painstaking process, that is why I am looking for a script that can recognize the dimensions and handle the resizing on its own. I'm not even sure its possible due to my inexperience with scripting, hence my journey to dreamincode.net.
personally, I'd pick server-side over javascript wherever possible. It's not painstaking at all (unless you aren't familiar with the server-side language). And also, then you could format the info in any way you desire. Then just pass the values back into the javascript for the window resize, and you're all set!
SlashRaid, In theory, yes, but my content varys from one line up to approximately twenty, with a fixed width. So unless someone is using a screen the size of their cell phone's to view my site it wouldn't be a problem. The content is just text, with some of it linked. If it were my call this wouldn't be an issue, but becuase I work with govt. employees that feel the need to flex their power to the fullest I constantly have to jump through hoops. Case in point, I could make the browser one uniform size that would fit everything nicely, but for the instances where there is less than the maximum amount of content my client doesn't want to see any blank space and in fact requested specifically what I am asking help for. Frustration is a feeling I have grown very familiar with.
I could do that, but it would be a painstaking process, that is why I am looking for a script that can recognize the dimensions and handle the resizing on its own. I'm not even sure its possible due to my inexperience with scripting, hence my journey to dreamincode.net.
personally, I'd pick server-side over javascript wherever possible. It's not painstaking at all (unless you aren't familiar with the server-side language). And also, then you could format the info in any way you desire. Then just pass the values back into the javascript for the window resize, and you're all set!
Therein lies the problem, I am not familiar with server-side language, not to mention my limited experience with javascript.
Well, using a little serverside and a little javascript, I can picture someone counting the words or counting the <br>'s or <p>'s or whatever and based on that multiplying $x pixels by $y lines/words/whatever to figure out aprox how big the window should be.
Does the server you are running this on have access to PHP and if you give me an example of one of the pages so I can see the code or how you are displaying it I could better suggest a solution.
Also, here are two examples of the windows I'm talking about and the disparity between the volume of content and the size of the window. I'm going to have to put the second example into another reply.
It looks like you are probably looping database records into a table. Couldn't you just check how many records you are going to output (queryName.RecordCount), and set the height based on that?
For example, say each table row is 25 pixels in height, you could add this to the head of the popup page (assuming queryName is the name of your cfquery and 500 pixels is the width you want):
In theory, wouldn't then be possible to have a large amount of content that would cause the window to be sized out side of the viewable screen width and length?
To me, I would thing you'd want to size the content with a standard size window that you know the user will be able to view.
What type of content is it? Images? What sizes do you anticipate?
that is a good point, and would me massively annoying to the users.
Just thinking out loud here so this may be way off, but can you place an empty named DIV at the end of the displayed info, then pick up to 'top' value of the DIV. That will give you the depth of the page (less DIV) and you could resize based on that. Use an onLoad option to ensure everything is loaded...
I could do that, but it would be a painstaking process, that is why I am looking for a script that can recognize the dimensions and handle the resizing on its own. I'm not even sure its possible due to my inexperience with scripting, hence my journey to dreamincode.net.
personally, I'd pick server-side over javascript wherever possible. It's not painstaking at all (unless you aren't familiar with the server-side language). And also, then you could format the info in any way you desire. Then just pass the values back into the javascript for the window resize, and you're all set!
Yes, This is the good solution passing values from serverside to script. its an easy solution too..
Sorry to "dig" this up. But I know of a way to get the numbers needed to resize a window to the size needed. Just use Javascript's DOM offsetHeight property.