...

View Full Version : Referencing and changing other windows....



daviiie
08-11-2006, 01:02 PM
function NewBrowser(url, thename, h, w, l) {

var newwindow;
string = 'height=' + h + ',width= ' + w + ',top=0, left=' + l + ',resizable=no'

newwindow = window.open(url, thename, string);
if (window.focus){
newwindow.focus()
}
setInterval("snap2()",500);


}

var newwindow;

function snap()
{

try{
xLoc = window.screenX
yLoc = window.screenY

if (xLoc != 257 & yLoc != 0)
{
window.moveTo(257,0);
}

}catch(err){}



}


I have a browser, that when you click on the appropriate area it will open a new window. But I want that new browser to remain in the place where it opens. As such I have created a snap function, that when you move the window it will immediately snap it back into place.

The problem I am having is that it is snapping the window that is opening the new browser and not the new browser itself. How do I reference the new browser window, can it be done by its name?

Any help would be appreciated.

Pyth007
08-11-2006, 03:48 PM
You could just make a global var to hold the window...


function NewBrowser(url, thename, h, w, l) {
// Removed first line...
string = 'height=' + h + ',width= ' + w + ',top=0, left=' + l + ',resizable=no'

newwindow = window.open(url, thename, string);
if (window.focus){
newwindow.focus()
}
setInterval("snap2()",500);
}

var newwindow; // Gloabl variable holding your window

function snap()
{
// Refer to gloabal thruout this function
try{
xLoc = newwindow.screenX
yLoc = newwindow.screenY

if (xLoc != 257 & yLoc != 0)
{
newwindow.moveTo(257,0);
}

}catch(err){}
}


As for the name property of the window, this is only useful when specifying a target of some other object (eg <a target="myWindow" href="www.codingforums.com">Click Me!</a> )



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum