PDA

View Full Version : multiple NewWindow w/separate parameters


hedbanger
03-28-2003, 06:29 AM
i have a page on which i want to open a new window at 500x400 with a tool bar and scrollable and also want to be able to open another window at 250x200 with no scroll and no toolbar.

i tried doing 2 functions and setting them off in brackets and specifying the pagename and parameters.
i'm probably way off track.


<SCRIPT LANGUAGE=JAVASCRIPT>
var win=null;
{function NewWindow(mypage,help,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',l ocation=no,directories=no,status=no,menubar='+yes+',toolbar=yes,resizable=yes';
win=window.open(mypage,prodsup,settings);
if(win.focus){win.focus();}} };
{function NewWindow(mypage,contact,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',l ocation=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,contact,settings);
if(win.focus){win.focus();}} };
</SCRIPT>
:confused:

HairyTeeth
03-28-2003, 06:51 AM
... without looking in depth at the script, remove the functions from the braces and give them different names. I don't know how you plan to call them but if you use the onload event handler in the body tag, it would look something like this:

<body onload="win01(param01,param02...etc);win02(param01,param02...etc)">


Hope that helped. Cheers.

kwhubby
03-28-2003, 07:28 AM
well thats kindov really Long just to open two windows the way you did it, and for what you wanted...
when you say toolbar do you mean only the toolbar...???
this will do what you want for the first one

var windowa = window.open("url","window id","scrollbars=1, location=1, directories=1, toolbar=1, navigation=1, resizable=1, menubar=1, status=1, width=500, hight=400")
(replace url with what the page url you want the popup to be, and the id can be anything, its not really important in this case)
this would make a 500x400 window with everything enabled, if you want one of those parts not to show, just change it from 1 to 0.

hopefully thats enough and you can figure out how to change the properties of that and make it work how ever you want.
P.s change the variable u use for the second popup, like windowb or something.

pss. don't put a { before you make a function, you only need put it after.... and whats all that extra script, i thought you only wanted to open 2 windows?

hedbanger
03-28-2003, 08:55 PM
thanks all.
hairy teeth, i appreciate your explanation. i think it helped my understanding of what's going on.
kwhubby, isn't it obvious!? all that extra code is me not knowing what i'm doing :o
... so i repeated the whole thing twice.
the bloated thing does get two windows to open and at the right sizes and with scroll on 1 and without on the other. the only thing i could get was a toolbar on one and not the other.

i'll give the suggestions a go.
thanks.

Mr J
03-28-2003, 11:15 PM
Try the following as well







<script>
function popup(theURL,Width,Height,Left,Top,atts){
var newWin=open(theURL,'','width='+Width+',height='+Height+',left='+Left+',top='+Top+',attributes='+atts +'' );
}
</script>
<a href="JavaScript:popup('page1.htm',500,400,100,100,'toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes, ')">Example one</a> <BR>
<a href="JavaScript:popup('page2.htm',250,200,100,100,'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, ')">Example two</a> <BR>


Lines in bold should be one continuous line.

Hasn't rendered correctly in this forum

hedbanger
03-28-2003, 11:47 PM
mr j,
thanks! that does the trick and is nice and tiny. it's going into my snippets directory.

thanks all!

hedbanger
03-29-2003, 04:25 AM
i've got my new windows working (though i'm still a little iffy on getting ALL the attributes to do my bidding).
this code works but i can't get the rollover to work. (it works fine without the newwindow stuff.)
(line breaks inserted to allow wrapping...)

<a href="http://meyer.custhelp.com/cgi-
bin/meyer.cfg/php/enduser/std_alp.php" onfocus="this.blur()"
onclick="NewWindow
(this.href,'prodsup','760','590','yes','center','yes')"; return false"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage
('prodSupt','','../images/product_support2-n.gif',1)"><img
src="../images/product_support2.gif" alt="Product Support"
width="132" height="20" border="0"></a>

this is the working rollover:
<a href="http://www.prodregister.com/anolon"
target="blank" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage
('registercookware','','../images/register_cookware2-
n.gif',1)"><img src="../images/register_cookware2.gif" alt="
Product Registration" name="registercookware" width="194"
height="20" border="0"></a>

Mr J
03-29-2003, 10:06 AM
Sorry but this doesn't tell me anything.

I need to see the actual script that goes with this.

For example:

you have

'yes','center','yes'

I need to see what the script is doing with these

hedbanger
03-31-2003, 08:54 PM
here it is (with added line breaks to allow wrapping...)

var win=null;
function NewWindow
(mypage,myname,w,h,scrollbars,pos,menubar)
{
if(pos=="random"){LeftPosition=(screen.width)?Math.floor
(Math.random()*(screen.width-w)):100;TopPosition=
(screen.height)?Math.floor(Math.random()*((screen.height-h)-
75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-
w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null)
{LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',
left='+LeftPosition+',scrollbars='+scrollbars+',location=no,
directories=no,status=no,menubar='+menubar+',toolbar=no,
resizable=yes';
win=window.open(mypage,myname,settings);
if(win.focus){win.focus();}}

Mr J
03-31-2003, 10:07 PM
I have tested the script you supplied and it works quite well.


I can only suggest that you check to see that you have not used a variable name that is also being used in the rollover script.


There was a typo in this line

(this.href,'prodsup','760','590','yes','center','yes')"; return false"




should be

(this.href,'prodsup','760','590','yes','center','yes'); return false"



(lose the quote after the closing bracket)

hedbanger
04-01-2003, 05:48 AM
thanks for spotting that.