Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Can I open windows of different sizes with one script?

Hallo

Utter Java newbie here, so this may be a silly question, I don't know.

I have the following script, which opens a new window of a certain size. Is it possible to put variables in for height and width, so I can open windows of several different sizes with the same script? In which case, how? (And how do I call it?)

Thanks

--

<script language='javascript'>
//-- This function opens the new, empty window named floater.
function openWindow(url) {
winStats='toolbar=no,location=no,directories=no,menubar=no,'
winStats+='scrollbars=yes,width=400,height=400'
if (navigator.appName.indexOf("Microsoft")>=0) {
winStats+=',left=10,top=10'
}else{
winStats+=',screenX=10,screenY=10'
}
floater=window.open(url,"",winStats)
}
//-->
</script>
[982 byte] By [Colm Osiris] at [2007-11-11 7:52:48]
# 1 Re: Can I open windows of different sizes with one script?
I've got a reply from another forum, but I thought I'd post it here, in case anyone else wants to know how to do this:

<script language='javascript' type="text/javascript">
//-- this function opens the new, empty window named floater
function openWindow(url,iW,iH) {
winStats='toolbar=no,location=no,directories=no,menubar=no,'
winStats+='scrollbars=yes,width=' + iW + ',height=' + iH
if (navigator.appName.indexOf("Microsoft")>=0) {
winStats+=',left=10,top=10'
}else{
winStats+=',screenX=10,screenY=10'
}
floater=window.open(url,"",winStats)
}
//-->
</script>

to call it:

<a href="javascript:openWindow('http://www.blahblahblah.com/html',400,400);">link</a>

[NB. :o = colon, little o]
Colm Osiris at 2007-11-11 22:37:11 >