?
Solved

Popup window with flexible size

Posted on 2003-02-27
4
Medium Priority
?
260 Views
Last Modified: 2012-08-13
I need to open a popup window which will be flexible in size. i.e. its height and width will be according to its document size. And the code should be in the main page. Is it possible?
0
Comment
Question by:Santanu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Accepted Solution

by:
bjorsq earned 88 total points
ID: 8032323
As far as I'm aware, this isn't possible. The problem lies in determining the size of the document loaded in the popup from the main window. It isn't a trivial task to determine the size of a document loaded in a window, and some documents will fit in a window by default (say if they consist of divs or tables with percentage widths set). Why not just make the popup resizeable and open it at a sensible size?

If the popup will just contain an image, then the task is a bit more straightforward, as you can access the width and height of the image quite easily:

var popWin = window.open('popup.html','popup','resizeable');
check = setTimeout("checkWin()",20);
function checkWin(){
  if(popWin.window.document.images[0]){
    clearTimeout(check);
    popWin.resizeTo(popWin.window.document.images[0].width,popWin.window.document.images[0].height);
    alert("width="+popWin.window.document.images[0].width+"\nheight="+popWin.window.document.images[0].height);
  }
}

This is just a quick example - I've tested it locally and it works, but I think the image needs to be loaded before you can access its dimensions, and I'm not sure if checking whether popWin.window.document.images[0] returns a true or false value will do this consistently.
 
0
 

Author Comment

by:Santanu
ID: 8033189
Thank you for your code. Its running well. But is there any process to get the div size or table size of a page which can be use to set the window size of that page.
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10095952
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: bjorsq {http:#8032323}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question