School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

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!




Dynamically Resize A Browser Window....

2 Pages V  1 2 >  

Dynamically Resize A Browser Window...., Javascript help

skape999

28 Aug, 2002 - 12:41 PM
Post #1

New D.I.C Head
*

Joined: 28 Aug, 2002
Posts: 8

...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. huh.gif

User is offlineProfile CardPM
+Quote Post


Cookie Mobster

RE: Dynamically Resize A Browser Window....

28 Aug, 2002 - 03:44 PM
Post #2

nooneenooneenooonee
Group Icon

Joined: 12 Oct, 2001
Posts: 4,724



Thanked: 3 times
Dream Kudos: 18
My Contributions
OK This is about the 6th time this same question has been asked. I'm just going to make it sticky to avoid confusion.
CODE

// resize the current window to the specified width,height
parent.resizeTo(width,height);


Cheers Sam
User is offlineProfile CardPM
+Quote Post

skape999

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 05:09 AM
Post #3

New D.I.C Head
*

Joined: 28 Aug, 2002
Posts: 8

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).
User is offlineProfile CardPM
+Quote Post

klewlis

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 05:55 AM
Post #4

cur tu me vexas?
*****

Joined: 9 Nov, 2001
Posts: 1,723

could you determine the size of the record on the server side, and then pass those values to the javascript?
User is offlineProfile CardPM
+Quote Post

skape999

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 06:12 AM
Post #5

New D.I.C Head
*

Joined: 28 Aug, 2002
Posts: 8

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.
User is offlineProfile CardPM
+Quote Post

SlashRaid

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 07:04 AM
Post #6

Dream.In.Force
*****

Joined: 21 Jan, 2002
Posts: 2,421

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?
User is offlineProfile CardPM
+Quote Post

klewlis

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 07:26 AM
Post #7

cur tu me vexas?
*****

Joined: 9 Nov, 2001
Posts: 1,723

QUOTE(skape999 @ Aug 29 2002, 09:12 AM)
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!
User is offlineProfile CardPM
+Quote Post

skape999

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 07:29 AM
Post #8

New D.I.C Head
*

Joined: 28 Aug, 2002
Posts: 8

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.
User is offlineProfile CardPM
+Quote Post

skape999

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 07:32 AM
Post #9

New D.I.C Head
*

Joined: 28 Aug, 2002
Posts: 8

QUOTE(klewlis @ Aug 29 2002, 09:26 AM)
QUOTE(skape999 @ Aug 29 2002, 09:12 AM)
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.
User is offlineProfile CardPM
+Quote Post

skyhawk133

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 08:30 AM
Post #10

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 16,842



Thanked: 151 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
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.
User is offlineProfile CardPM
+Quote Post

skape999

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 09:18 AM
Post #11

New D.I.C Head
*

Joined: 28 Aug, 2002
Posts: 8

I'm not sure what PHP is, but I have attached one of the pages I am trying to manipulate....


Attached File(s)
Attached File  soft_track.cfm ( 6.72k ) Number of downloads: 55
User is offlineProfile CardPM
+Quote Post

skape999

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 09:29 AM
Post #12

New D.I.C Head
*

Joined: 28 Aug, 2002
Posts: 8

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.


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

skape999

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 09:30 AM
Post #13

New D.I.C Head
*

Joined: 28 Aug, 2002
Posts: 8

Here's the second example....


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

klewlis

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 04:14 PM
Post #14

cur tu me vexas?
*****

Joined: 9 Nov, 2001
Posts: 1,723

tell them to suck it up and deal with white space. :)
User is offlineProfile CardPM
+Quote Post

supernova333

RE: Dynamically Resize A Browser Window....

29 Aug, 2002 - 08:23 PM
Post #15

D.I.C Addict
****

Joined: 12 Mar, 2002
Posts: 590



Thanked: 3 times
My Contributions
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):

CODE

<cfset windowHeight=queryName.RecordCount*25>
<script>
parent.resizeTo(500,<cfoutput>#Trim(windowHeight)#</cfoutput>);
</script>

User is offlineProfile CardPM
+Quote Post

devian

RE: Dynamically Resize A Browser Window....

4 Jun, 2003 - 04:35 AM
Post #16

New D.I.C Head
*

Joined: 27 Apr, 2003
Posts: 43

QUOTE(SlashRaid @ Aug 29 2002, 08:04 AM)
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. sad.gif
User is offlineProfile CardPM
+Quote Post

.sva

RE: Dynamically Resize A Browser Window....

23 Jun, 2003 - 11:36 AM
Post #17

New D.I.C Head
*

Joined: 26 May, 2003
Posts: 33



Thanked: 1 times
My Contributions
QUOTE(smckone @ Aug 28 2002, 04:44 PM)
CODE

// resize the current window to the specified width,height
parent.resizeTo(width,height);

is there any way to restore the browser window to the users prefered size?
User is offlineProfile CardPM
+Quote Post

Jayen

RE: Dynamically Resize A Browser Window....

22 Nov, 2004 - 08:52 AM
Post #18

New D.I.C Head
*

Joined: 4 May, 2004
Posts: 12



Thanked: 1 times
My Contributions
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...
User is offlineProfile CardPM
+Quote Post

phanindra

RE: Dynamically Resize A Browser Window....

11 Jun, 2006 - 10:45 PM
Post #19

New D.I.C Head
*

Joined: 11 Jun, 2006
Posts: 2


My Contributions
QUOTE(klewlis @ 29 Aug, 2002 - 07:18 AM) *

QUOTE(skape999 @ Aug 29 2002, 09:12 AM)
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..
User is offlineProfile CardPM
+Quote Post

snoj

RE: Dynamically Resize A Browser Window....

4 May, 2007 - 10:48 PM
Post #20

Now with 10% more nom!
Group Icon

Joined: 31 Mar, 2003
Posts: 3,369



Thanked: 29 times
Dream Kudos: 775
My Contributions
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.

Internet Explorer
Mozilla/Firefox
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic

Time is now: 11/6/09 04:47PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month