Forum Moderators: open

Message Too Old, No Replies

best way to open a new window with these requirements.

new window

         

messmaster

5:06 pm on May 30, 2006 (gmt 0)



Hi everyone
I have a splash page which leads to the main site which i need to open in a new window (450x628)..some things that must happen are..

window is centered vert and horiz on the screen

no toolbars, scrollbars etc

scrollbars ONLY appear when needed for low resolutions

thats it
although it doesnt sound too complicated i have tried various methods and cant get it working
thanks for anyone who can help meeee

Trace

7:09 pm on May 30, 2006 (gmt 0)

10+ Year Member



How's this? It's a generic function that I use in a lot of pages that can accomplish what you need and then some.

Add this to inside your head tags

<script type="text/javascript">
var win=null;
function NewWindow(mypage,myname,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+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
}
</script>

And then use this to call it

<a href="http://www.google.com" onclick="NewWindow(this.href,'mywin','450','628','no','center');return false" onfocus="this.blur()">YourLinkText</a>

Change the href to your URL
'mywin' is the name given to the window
450 is your width
628 is you height
the following 'no' is your scroll bars
and the 'center' is the position for your popup