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 5 of 5
  1. #1
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Question Problem with re-setting/styling open windows in NN an FF

    I New to this forum so i hope im placing this question ther write place

    Im also an newbie in Javscript... so pleas be gentel

    Im making a script that will open new windows by "scroling" them down and right. The script shal handel more than one window and shal also be able to reopen an allready open window with new settings and new place on the screen.

    this is the part of the script i use to open and palce the window:
    ----------------------------------------------------------

    vindue = window.open("",vinNavn,vinSet+",width=1,height=1,"+vinOpt);
    vindue.focus();
    vindue.moveTo(vinVens,vinTop);
    for (sideHoej = 1; sideHoej < vinHoej; sideHoej += stepNed) {
    vindue.resizeTo(1,sideHoej);
    }
    for (sideBred = 1; sideBred < vinBred; sideBred += stepHen) {
    vindue.resizeTo(sideBred+6,sideHoej);
    }
    vindue.location = openSide;
    vindue.focus();

    ----------------------------------------------------------
    the variabels are set befor this part
    The script works fine in both EI NN and FF (Im on a mac) as long as i only use it to open new windows. If i try to open an already open window ("Reopen") with new setting (Hight, width and so) i get truble in NN and FF, in IE it works fine.
    you can see the script in action here:
    http://home19.inet.tele.dk/jgom/test...ow-test-1.html
    I have 5 links that shal open a window. Link 3 to 5 shal open window 2 3 and 4 . Link 1 and 2 shal open window 1 .
    Using link 1 window 1 shal be full scren width and 300px high and centerd on screen.
    Using link 2 window 1 shal be full scren high and 300px widht and centerd on screen.

    The problem is that when window 1 is open and i click link 2 window 1 takes the right new hight and width but place it at 0,0 (not centerd) if i clik agin i centers. (this also happen the other way around)

    Dos annyone have an ideer on hov i can get this to work ??
    I have tryde by inserting a funktion to close the window if it was already open, and then open it agin. but cud not get this to work

    I realy hope someone can help mee
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by Jesper Møller
    The script works fine in both EI NN and FF (Im on a mac) as long as i only use it to open new windows. If i try to open an already open window ("Reopen") with new setting (Hight, width and so) i get truble in NN and FF, in IE it works fine.

    I have tryde by inserting a funktion to close the window if it was already open, and then open it agin. but cud not get this to work
    That's exactly what you have to do to be certain of getting the behaviour you want.

    You need to maintain a table that contains both a reference to each window opened, and separately its name. The name must be separate because you do not have permission to read the reference.name property in some browsers.
    Before opening a window, scan the table for a name match, if found and reference.closed != true, call reference.close() .
    If no name match is found, open the new window and add its reference and its specified name to the table.

    This is a common question, so recently I wrote this routine to manage re-opening of windows with different parameters. It uses the algorithm described above.
    Code:
    <HTML>
    <BODY>
    
    <SCRIPT type='text/javascript'>
    
    SmartPop=/*284329323030362053204368616C6D657273*/
    { 
     winData: {ref:[], title:[] },
     
     up:function(locn, wName, paramString)
     {
      for(var i=0; i<this.winData.ref.length && this.winData.title[i]!=wName ; i++)
      ;
     
      if( i!=this.winData.ref.length && this.winData.ref[i].closed==false )
       this.winData.ref[i].close();
     
      if(locn != "")
       { 
        this.winData.ref[i]=window.open(locn, wName, paramString);
        this.winData.title[i]=wName;
       } 
       
      return false; 
     }
    }
    
    </SCRIPT>
    
    <A HREF='#' onclick='return SmartPop.up("http://google.com","Google","width=200,height=200,top=200,left=200")'>Google 200x200</A><BR>
    <A HREF='#' onclick='return SmartPop.up("http://google.com","Google","width=300,height=300,top=200,left=200")'>Google 300x300</A><BR>
    <A HREF='#' onclick='return SmartPop.up("http://google.com","Google","width=400,height=400,top=200,left=200")'>Google 400x400</A><BR>
    <A HREF='#' onclick='return SmartPop.up("","Google")'>Close Google</A><BR>
    
    
    <A HREF='#' onclick='return SmartPop.up("http://opera.com","Opera","width=200,height=200,top=200,left=600")'>Opera 200x200</A><BR>
    <A HREF='#' onclick='return SmartPop.up("http://opera.com","Opera","width=300,height=300,top=200,left=500")'>Opera 300x300</A><BR>
    <A HREF='#' onclick='return SmartPop.up("http://opera.com","Opera","width=400,height=400,top=200,left=400")'>Opera 400x400</A><BR>
    <A HREF='#' onclick='return SmartPop.up("","Opera")'>Close Opera</A><BR>
    </BODY>
    </HTML>

  • #3
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    sorry ... but i simply dont understand what u meen

    A table ?

    Why cant i close another window by simply call its name ??

    Like this script dos

    var MPClosePopCount1 = 0;
    function MPCloseWin1() {
    MPClosePopCount1++;
    self.close();
    }
    i
    t works...

    my script to close the windows i have opend ??

    your exampel with 3 links for 3 windows is NOT an option, the script shall handel all size of windows with all position posible and i dont know what they will be calld
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #4
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    This is how the links look:

    <p><a href="#" onclick="CSAction(new Array(/*CMP*/'C08D682C1'));return CSClickReturn();" csclick="C08D682C1">Click for bredt &quot;SlideWindow1&quot;</a></p>
    <p></p>
    <p><a href="#" onclick="CSAction(new Array(/*CMP*/'C08D72672'));return CSClickReturn();" csclick="C08D72672">Click for h&oslash;jt &quot;SlideWindow1&quot;</a></p>
    <p></p>
    <p><a href="#" onclick="CSAction(new Array(/*CMP*/'C0900CB92'));return CSClickReturn();" csclick="C0900CB92">Click for bredt &quot;SlideWindow2&quot;</a></p>


    And the variabels ar sent to the script like this:

    <script><!--
    CSAct[/*CMP*/ 'C08D682C1'] = new Array(JMSlideOpenWindow,/*URL*/ 'slideopenwindow1.html',5,'SlideWindow1',false,true,300,1500,false,false,0,0,true,false,false,false, false,false,false);
    CSAct[/*CMP*/ 'C08D72672'] = new Array(JMSlideOpenWindow,/*URL*/ 'slideopenwindow1.html',5,'SlideWindow1',false,true,1300,500,false,false,0,0,true,false,false,false, false,false,false);
    CSAct[/*CMP*/ 'C0900CB92'] = new Array(JMSlideOpenWindow,/*URL*/ 'slideopenwindow2.html',5,'SlideWindow2',false,true,400,1500,false,false,0,0,true,false,false,false, false,false,false);


    I have (with no luck) tryd to merge this code in to mine so it fits my needs:
    if (action[1] != "" && typeof MPStoreOpenWin2 != "undefined") {
    if (typeof MPStoreOpenWin2[action[1]] == "object") {
    var thisPopup = MPStoreOpenWin2[action[1]];
    if (!thisPopup.closed) thisPopup.close();
    }
    }
    But cant get i to work
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #5
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by Jesper Møller
    sorry ... but i simply dont understand what u meen

    A table ?

    Why cant i close another window by simply call its name ??
    The only way to close another window is to call the close method of the reference to that window, which you (should have) saved when you opened it.
    Like this script dos

    var MPClosePopCount1 = 0;
    function MPCloseWin1() {
    MPClosePopCount1++;
    self.close();
    }
    i
    t works...
    That function increments a variable then closes ( or tries to close ) its own window, not another.
    my script to close the windows i have opend ??

    your exampel with 3 links for 3 windows is NOT an option, the script shall handel all size of windows with all position posible
    That script can open any size window if passed the proper parameters, the links were just for demonstration purposes. It prevents re-opening of an existing window, (that is to say a window with the same name) without closing it first.
    and i dont know what they will be calld
    Of course you know, its the second parameter of window.open. If you pass it as "", then you can open only one window at a time.
    If you are content to open only one window, then modify your existing code from:
    Code:
    // Close window if its already open [No it doesn't]
    vindue = window.open("",vinNavn,vinSet+",width=1,height=1,"+vinOpt);
    vindue.focus();
    to
    Code:
    if(typeof vindue!='undefined' && typeof vindue.closed!='undefined' && vindue.closed==false)
     vindue.close();
    vindue = window.open("",vinNavn,vinSet+",width=1,height=1,"+vinOpt);
    vindue.focus();
    response.close();


  •  

    Posting Permissions

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