FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Opening window in different size...

 


joxang
How should I code a link to open a window of a certain size? (e.g. 200x400pix).

I have a media page with links to different video clips (.mov). I want tje clips embedded in new pages, and want the links to open to new windows that are only marginally bigger than the clips themselves.

Thanks!
CrimsonStrange
This is a piece of code that I've been using for years now. It'll open a new window to your exact specifications, and I've never had a problem using it in any browser.
____________________________________________

TO OPEN A NEW WINDOW TO YOUR EXACT SPECIFICATIONS:
0=NO 1=YES

NOTE: DON'T USE target="_blank" with this. It opens a new window automatically.

<a href="javascript:void(0)" ONCLICK="open('NAME_OF_YOUR_WINDOW_PAGE.html','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=800,height=600')">Open A Window</a>


And to close that same window:

<a href="javascript:window.close()">Close Window</a>

OF COURSE, YOU CAN USE IMAGES OR A BUTTON FOR THE LINK, TOO.


Hope this helps you out, joxang. Smile


PS: I'm sure there's a simplified version of the code above nowadays. Try going to DynamicDrive.com and looking under their Window and Frames section.
DanielXP
Put below into the HEAD:

Code:
<script language="javascript" 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>


The put below code where you want the link

Code:
<a href="URL" onclick="NewWindow(this.href,'mywin','Width','Height','no','center');return false" onfocus="this.blur()">LINK TEXT</a>


you need to change

URL - Where you want the popup to display
mywin - Window name (can have a space!) this give the window a hidden name
Width - Width of the popup
Height - Height of the popup
LINK TEXT - What you would like the link text to display

Hope this helped!
joxang
Thanks a lot to you both!! I'll try them out.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.