Solved

Open a auto sizeable window

Posted on 2006-11-13
5
204 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
 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

734 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