[Javascript] auto resizing a window

Peter Brunone peter at brunone.com
Mon Nov 5 17:50:12 CST 2001


Kyle,

    (Phil may be asleep right now, so I'll step in)

    Javascript conditional statements, like functions and other structures,
look like this:

if(condition) {
    do stuff here;
    }

    So the section that looks like this:

)
if (top.frames.length!=0)
 top.location=self.document.location;
 self.moveTo(0,0)
 self.resizeTo(675,600)
)

should look like this:

if (top.frames.length!=0) {
    top.location=self.document.location;
    self.moveTo(0,0);
    self.resizeTo(675,600);
    }

    Actually, though, unless you need to break out of somebody else's
frameset or move the window, you can slim the whole thing down to

self.resizeTo(675,600);

    Let us know if you have additional questions.  Also, there are plenty of
Javascript references off the main list page at
http://www.mountaindragon.com/javascript/resources.htm .

Cheers,

Peter

----- Original Message -----
From: "Kelly, Kyle" <Kyle at admin.usf.edu>
To: <javascript at LaTech.edu>
Sent: Monday, November 05, 2001 5:00 PM
Subject: RE: [Javascript] auto resizing a window


| Phil,
|
| Are you on ALL of the listservs? It is my great fortune for you to be on
| them all, ;-).
|
| I'm even newer to javascript than to vbscript, asp, etc, so please forgive
| my questions.
|
| Will this code work if the initial page has no frames?
|
| Here is the entire page that I'm trying to make work. I should have
included
| it to begin with. It's not like everyone doesn't constantly say to!
|
| <Begin Code>
|
| <html><link rel="STYLESHEET" type="text/css" href="/mycss.css">
| <script language="JavaScript">
| <!--
| function MM_openBrWindow(theURL,winName,features) { //v2.0
|   window.open(theURL,winName,features);
| }
| //-->
| <!-- START
| )
| if (top.frames.length!=0)
| top.location=self.document.location;
| self.moveTo(0,0)
| self.resizeTo(675,600)
| )
| // END -->
| </script>
|
|
| <p>&nbsp;</p>
| <p>&nbsp;</p>
| <p>&nbsp;</p>
| <p>&nbsp;</p>
| <table width="500" border="0" align="center">
|   <tr>
|     <td>
|       <p align="center"><font size="4">Welcome to TheAllThing</font></p>
|       <p align="center"><font size="4">TheAllThing is best viewed at
| 1024X768
|         <br>
|         Resolution on an Internet Explorer</font></p>
|       <p align="center"><font size="4">&lt;<a href="#"
|
onMouseOver="MM_openBrWindow('default1.htm','','scrollbars=yes,width=675,hei
| ght=600')">Enter</a>&gt;</font></p>
| </td>
|   </tr>
| </table>
| <p>&nbsp;</p>
| </html>
|
| </End Code>
|
| -----Original Message-----
| From: Phil Winstanley [mailto:phil.winstanley at creations.co.uk]
| Sent: Monday, November 05, 2001 5:20 PM
| To: 'javascript at LaTech.edu'
| Subject: RE: [Javascript] auto resizing a window
|
|
|
| Modify this one a little.
|
| <SCRIPT language="JavaScript">
| <!-- START
| if (top.frames.length!=0)
| top.location=self.document.location;
| self.moveTo(0,0)
| self.resizeTo(screen.availWidth,screen.availHeight)
| // END -->
| </script>
|
| Plip.
| _____________________________
| Company Idiot
| Creations Group Limited
| _____________________________
|
|
|
| -----Original Message-----
| From: Kelly, Kyle [ mailto:Kyle at admin.usf.edu
<mailto:Kyle at admin.usf.edu> ]
| Sent: 05 November 2001 22:17
| To: 'javascript at LaTech.edu'
| Subject: [Javascript] auto resizing a window
|
| Greetings,
|
| Is there a way to automatically resize a window to certain parameters, say
| 675x600? In other words, when a user hits my page, I want the page to
| automatically resize itself to 675x600. What I'm doing now is to have the
| user click on an <ENTER> link that opens another page that is 675x600.
This
| however is a pain in the behind.
|
| Can this be done with out having the user hit the <ENTER> link, and
opening
| another window? I'd like only one window to open, as constant additional
| windows annoy me, and undoubtedly others as well.
|
| Thanks in advance for any suggestions.
|
| Thank You,
|
| Kyle




More information about the Javascript mailing list