JavaScript Windows 2
syllabus | schedule | assignments | Web Resources | ARTC courses
[Intro]     [Tags]     [CSSStyles]     [Lists]     [Links]     [ImageTypes]     [Optimization]    [GlobalCSS]     [CSSBackgrounds]
[Tables]     [Slices]     [IR Rollovers]     [Animated GIFs]     [JS Rollovers]     [CSS Margins]     [Windows]     [Video]     [Metatags]     [Imagemaps]     [FormInput]     [FormAtttributes]    [AdvancedForms]    [WhatisJavaScript]    [Windows2]    [Windows3]   
DISCLAIMER: Much of the code below tested fine in IE, but was hit or miss with SAFARI. Do lots of testing in various browsers!

Opening, Sizing and Placing Window Using SELF

//keywords for monitor resolution - IE, Safari
screen.height
screen.width

//keywords for monitor resolution - Netscape
screenY
screenX

In Head: (of document you are trying to open)

<script language="javascript" type="text/javascript">

//use a combination of the following:

//opening window resizes itself vs. putting the size in the link like previous examples
<
Windows Lecture 1>

self.resizeTo(screen.width, screen.height); //resizes to fill monitor screen
self.resizeTo(300, 400); //resizes to specific size

//opening window positions itself vs. using "top, left" in the link like previous examples
<
Windows Lecture 1>

self.moveTo(0, 0); //0,0 = upper left

//variables to figure out position no matter the screen res
//for centering window:

x = (screen.width - 300) / 2; //(screen width - window width) / 2
y = (screen.height - 400) / 2; //(screen height - window height) / 2
self.moveTo(x, y);

</script>

SAMPLE:

<script language="javascript" type="text/javascript">

var h = 400; //arbitrary window height
var w = 300; //arbitrary window width

var x = (screen.width - w) / 2; //window position based on screen size
var y = (screen.height - h) / 2;

self.resizeTo(w,h); //size window
self.moveTo(x,y); //position window

</script>

 

Closing Window Using SELF

In BODY: (of document you are trying to open)

<a href="javascript:self.close();">close window </a> //works for IE

 

Window Focus is used to bring a pop-up window to the foreground if it is already open, but behind other windows.

In BODY: (of document you are trying to open)

<body onLoad="window.focus();">