...

View Full Version : Help!! Variable being wiped......



daviiie
08-11-2006, 04:33 PM
function NewBrowser(url, thename, h, w, l) {
string = 'height=' + h + ',width= ' + w + ',top=0, left=' + l + ',resizable=no';
var newwindow = window.open(url, thename, string);
if (window.focus) {
newwindow.focus();
}
myArray['main'] = newwindow;
timeout()

}

function timeout()
{
setInterval("snap(myArray['main'])", 500);
}


function snap(windowObj) {
try {

xLoc = windowObj.screenX;
yLoc = windowObj.screenY;

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

}
}



This is my code, and it works...kinda. When I click on my link and open a new browser, as its loading if I move the browser it will snap back into position. When the page loads completely this stops working. Its like the variable myArray['main'] is being overwritten.

Could anyone shed any light?

Beagle
08-14-2006, 04:08 PM
try defining the variable in the global scope:



var myArray; // *** Ensure the variable is defined globally ***

function NewBrowser(url, thename, h, w, l) {
string = 'height=' + h + ',width= ' + w + ',top=0, left=' + l + ',resizable=no';
var newwindow = window.open(url, thename, string);
if (window.focus) {
newwindow.focus();
}
myArray['main'] = newwindow;
timeout();
}

function timeout()
{
setInterval("snap(myArray['main'])", 500);
}

function snap(windowObj) {
try {

xLoc = windowObj.screenX;
yLoc = windowObj.screenY;

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

}
}


See if that works.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum