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 9 of 9
  1. #1
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts

    odd result when using two javascript:newWin('url') scripts together

    when i try to use the same script twice on a page (renamed appropriately i assume), i get the oddest thing happening. the width & height variables in the first instance of the script (directly below) dont get read... or they get overwritten. in any case... the window opens full screen.

    the only way i can get around this is to open a link in the second script using <a href="javascript:newWinPDF('url'), keep that open, and THEN for some reason the other script works properly...

    any ideas why this may be

    i think you may be able to see it at www.enviromark.ca/sitetest/english/products.html --> Greyline --> Stingray

    Code:
    <script type=text/javascript> 
    function newWin(urlLoc) {
      _winName = "popupSelect";
      _info  = "toolbar=no";     // yes|no 
      _info += ",location=no";   // yes|no 
      _info += ",directories=no";// yes|no 
      _info += ",status=no";    // yes|no 
      _info += ",menubar=no";    // yes|no 
      _info += ",scrollbars=no";// yes|no 
      _info += ",resizable=yes"; // yes|no 
      _info += ",dependent";     // close the parent, close the popup, omit if you want otherwise 
      _info += ",height=250";
      _info += ",width=425";
      _info += ",left=465";
      _info += ",top=100";
      DispWin=window.open(urlLoc,_winName,_info);
    } 
          </script>
    	  
            <script type=text/javascript> 
    function newWinPDF(urlLoc) {
      _winName = "MyNewWindow1";
      _info  = "toolbar=yes";     // yes|no 
      _info += ",location=no";   // yes|no 
      _info += ",directories=no";// yes|no 
      _info += ",status=no";    // yes|no 
      _info += ",menubar=no";    // yes|no 
      _info += ",scrollbars=yes";// yes|no 
      _info += ",resizable=yes"; // yes|no 
      _info += ",dependent";     // close the parent, close the popup, omit if you want otherwise 
      DispWin=window.open(urlLoc,_winName,_info);
    } 
          </script>
    Last edited by canadianjameson; 05-31-2004 at 08:18 PM. Reason: wrong link
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That script is written to be reused by numerous links. Why do you feel the need for two instances of the same script? That defeats its purpose. However, if you want to continue this folly. Change the window name and variable names.

  • #3
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    i use two instances of the function because they require different setting, as seen in the yes/no differences in the two scripts.

    as for using different function name & window names, i have already done that. unless i'm crazy

    What else is going wrong.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Change your global variable names or make them local to the function. But if it was me, I would use the same function and pass the various window attributes as arguements.

  • #5
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Willy Duitt
    ... But if it was me, I would use the same function and pass the various window attributes as arguements.
    can you give me a code example of how i would do this?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #6
    Regular Coder
    Join Date
    May 2004
    Location
    Alabama, USA
    Posts
    237
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Like this...
    Code:
    // from the X Library v3.15.2, Licensed LGPL (cross-browser.com)
    
    function xWindow(name, w, h, x, y, loc, men, res, scr, sta, too)
    {
      var f = '';
      if (w && h) {
        if (document.layers) f = 'screenX=' + x + ',screenY=' + y;
        else f = 'left=' + x + ',top=' + y;
        f += ',width=' + w + ',height=' + h + ',';
      }
      f += ('location='+loc+',menubar='+men+',resizable='+res
        +',scrollbars='+scr+',status='+sta+',toolbar='+too);
      this.features = f;
      this.name = name;
      this.load = function(sUrl) {
        if (this.wnd && !this.wnd.closed) this.wnd.location.href = sUrl;
        else this.wnd = window.open(sUrl, this.name, this.features);
        this.wnd.focus();
        return false;
      }
    }

  • #7
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    how would i impliment this?

    is it in conjunction with the above scripts, or is it another window script?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #8
    Regular Coder
    Join Date
    May 2004
    Location
    Alabama, USA
    Posts
    237
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is yet another new window script ;-)

    Have a look here.

  • #9
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    haha, the issue being that I, as a supreme n00bie, enjoyed the idiotproofness of my other scripts

    do you know how i'd modify those to fix my problem, willy told me how above, but i couldnt make it work
    Last edited by canadianjameson; 06-01-2004 at 03:51 PM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)


  •  

    Posting Permissions

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