Center pop up

the tutorial on center popup window is cool
but I have lots of popup window in my site and I don’t want to type long list of code on each and every button.

So I want to know - is there any way that I can create a function and use it again and again.

here is what i tried
[AS]Movieclip.prototype.openWinCentre = function (url, winName, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable) {
getURL (“javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open(’” + url + “’,’” + winName + “’,’” + “width=” + w + “,height=” + h + “,toolbar=” + toolbar + “,location=” + location + “,directories=” + directories + “,status=” + status + “,menubar=” + menubar + “,scrollbars=” + scrollbars + “,resizable=” + resizable + “,top=’+((screen.height/2)-(” + h/2 + “))+’,left=’+((screen.width/2)-(” + w/2 + “))+’” + “’)}else{myWin.focus();};void(0);”);
}
function pop() {
address = “http://www.yahoo.com”;
target_winName = “hallweir”;
width = 400;
height = 300;
toolbar = 0;
location = 0;
directories = 0;
status = 0;
menubar = 0;
scrollbars = 0;
resizable = 0;
//sends data back to the function
openWinCentre(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);
}
thumb.thumbnail.but1.onRelease = function() {
pop();}[/AS]

this is o.k. but what about the address - address for each and every button is different.

Any Suggestion.
Thanks

I don’t get the issue.
you are passing the var ‘address’ through and so each time you use the function pop() it is passing it across.

[AS]function pop(address) {
var target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable;
target_winName = “hallweir”;
width = 400;
height = 300;
toolbar = 0;
location = 0;
directories = 0;
status = 0;
menubar = 0;
scrollbars = 0;
resizable = 0;
openWinCentre(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);
}
thumb.thumbnail.but1.onRelease = function() {
pop(“http://www.yahoo.com”);
}[/AS]
?? =)

That is the same thing as declaring it below in a variable…

You didn’t understand his question, I believe. He (he, right?) wants to use a different address for each Button, I told him how. :wink:

thanks kode
I have not tested but I am sure it will work for me.

You’re welcome, alnoor. :stuck_out_tongue: