Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Strange behavior (for a newbie anyway)

    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?


    Code:
    <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>
    Code:
    <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>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,917
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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.

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    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....

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •