...

View Full Version : Problem with re-setting/styling open windows in NN an FF



Jesper Møller
06-03-2006, 08:46 PM
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 :o

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. :rolleyes:

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/slideopenwindow-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) :mad:

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

Arty Effem
06-04-2006, 12:15 AM
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.

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

Jesper Møller
06-04-2006, 12:29 AM
sorry ... but i simply dont understand what u meen :confused:

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

Jesper Møller
06-04-2006, 01:01 AM
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 :mad:

Arty Effem
06-04-2006, 04:31 AM
sorry ... but i simply dont understand what u meen :confused:

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 calldOf 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:
// Close window if its already open [No it doesn't]
vindue = window.open("",vinNavn,vinSet+",width=1,height=1,"+vinOpt);
vindue.focus();
to

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();



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum