...

View Full Version : Strange behavior (for a newbie anyway)



panthers7171
08-26-2007, 04:19 PM
I have these two functions in a page and regardless of whether I call a "chart" or a "link"...the only function that works is always the 2nd one (in this case "Link").

For 99.9% of my pages...there is either one or the other...and they work great. However...there are several pages that need both...yet it acts strangely.

Any suggestions?



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

var screenCenterW = screen.availWidth/2;
var screenCenterH = screen.availHeight/2;
var width = screen.availWidth/1.1;
var height = screen.availHeight/2;
var placementLeft = ((screenCenterW) - (width/2) - 20);
var placementTop = ((screenCenterH) - (height/1.1));

function popupChart(win, target)
{
if(!window[target] || window[target].closed) {
newWindow = window.open(win,target,'toolbar=no,location=no,scrollbars=yes,resizable=yes,width='+width+',height=' +height+',left='+placementLeft+',top='+placementTop+'');
}
newWindow.focus();
}
</script>



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

var screenCenterW = screen.availWidth/2;
var screenCenterH = screen.availHeight/2;
var width = screen.availWidth/3;
var height = screen.availHeight/3;
var placementLeft = ((screenCenterW) - (width/2) - 20);
var placementTop = ((screenCenterH) - (height/2));

function popupLink(win, target)
{
if(!window[target] || window[target].closed) {
newWindow = window.open(win,target,'toolbar=no,location=no,scrollbars=yes,resizable=yes,width='+width+',height=' +height+',left='+placementLeft+',top='+placementTop+'');
}
newWindow.focus();
}
</script>

Philip M
08-26-2007, 05:23 PM
Many of the variable names in your scripts are duplicated, and the second instance over-writes the first.

Change the names of all the variables in your second script, e.g.

var screenCenterW2 = screen.availWidth/2;
var screenCenterH2 = screen.availHeight/2;
var width2 = screen.availWidth/1.1;

.. and so on.

panthers7171
08-26-2007, 06:52 PM
Many of the variable names in your scripts are duplicated, and the second instance over-writes the first.

Change the names of all the variables in your second script, e.g.

var screenCenterW2 = screen.availWidth/2;
var screenCenterH2 = screen.availHeight/2;
var width2 = screen.availWidth/1.1;

.. and so on.

Wow...even as a newbie I should have seen that one....:eek:

Anyway...thanks for the quick response...works great now!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum