Solved

Open a auto sizeable window

Posted on 2006-11-13
5
202 Views
Last Modified: 2010-05-18
I've got a page with an ASP datagrid on it that currently opens in a pop-up using a script.
What I want to do is size this window based on the size of the datagrid. I've been able to do this
with images in the past, but i haven't been able to get the code to work for the datagrid.
How would I do this?


TIA
0
Comment
Question by:Mike Miller
[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
5 Comments
 
LVL 8

Expert Comment

by:RozanaZ
ID: 17930978
0
 

Author Comment

by:Mike Miller
ID: 17931060
that looks like a great way to open a 400 x 400 window. can you answer my question?
0
 
LVL 6

Expert Comment

by:system_down
ID: 17931097
<html>
<head>
<script type="text/javascript">

function open_win(h,w)
{
window.open("http://www.w3schools.com","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width="+w+", height="+h+")
}
</script>
</head>

<body>
<form>
<input type="button" value="Open Window" onclick="open_win("+datagrid.height+","+datagrid.width+")">
</form>
</body>

</html>

0
 
LVL 8

Expert Comment

by:RozanaZ
ID: 17931149
Ok, if you have dynamic datagrid dimensions:

<html>
<head>
<script type="text/javascript">
function open_win()
{
  winObj = window.open("2.html","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400");
  winWidth = winObj.document.getElementById("test1").width;
  winHeight = winObj.document.getElementById("test1").height;
  winObj.resizeTo(winWidth,winHeight);
}
</script>
</head>

<body>
<form>
<input type="button" value="Open Window" onclick="open_win()">
</form>
</body>

</html>


Where 'test1' is id of your datagrid.
0
 
LVL 17

Accepted Solution

by:
gops1 earned 500 total points
ID: 17936648
Here is sample script which you can try out:
 
Code for the Parent Window:
==================

<html>
      <head>
            <title>Script Demo</title>
            <script language="JavaScript">
                  function openWin(){
                        var child=window.open("Q_22058597-child.html","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes");
                  }
            </script>
      </head>
<body>
      <a href="#" onclick="openWin();return false;">Open Child</a>
</body>
</html>



Code for the Child:
============

<html>
      <head>
            <title>Script Demo</title>
            <style>
                  body{
                        margin:0;
                  }
            </style>
            <script language="JavaScript">
                  function getWinResized(){
                        var dataObj=document.getElementById('childData');
                        var ht=dataObj.offsetHeight+40;
                        var wd=dataObj.offsetWidth+35;
                        window.resizeTo(wd,ht);
                  }
            </script>
      </head>
<body onload="getWinResized()">
      <table cellpadding="0" cellspacing="10" border="0" id="childData">
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
            <tr>
                  <td>col1</td>
                  <td>col2</td>
                  <td>col3</td>
            </tr>
      </table>
</body>
</html>

=================================

Experiment it by adding more rows to the table inside child window.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Geolocation works...sometimes 2 37
Set a parameter in a properties file and use in html table. 14 58
How does this modal gets closed? 6 41
Check for Numeric Phone Field 14 47
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

732 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