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

onClick="window.open" - window issues

 


saeleyjnr
I've got my site set-up so that when you click a link on the home page it launches the site in a new resized window.

This is the code:

Code:
<a href="javascript:;" onClick="window.open('news.htm','signup','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,HEIGHT=587,WIDTH=820');">
   <img border="0" src="images/buttons/ENTER.jpg" width="171" height="94"></a>


But, i'd like the window to be centered and not in the top left hand corner of the screen when it's launched.

What's the code to do this?
LukeakaDanish
I usually use some variant of the following function (written by me)

Code:


<script type="text/javascript">

winSizeH = 500
winSizeW = 600

function openWin(location) {
   leftpos = 0;
   toppos = 0;
   if (screen) {
      leftpos = (screen.width/2) - (winSizeW/2);
      toppos = (screen.height/2) - (winSizeH/2);
   }
   the_window = window.open(location, 'JavascriptWindow', 'width='+winSizeW+', height='+winSizeH+', status=no, toolbar=no, location=no, menubar=no, directories=no, resizeable=no, scrollbars=no, left='+leftpos+', top='+toppos);
   
}



I hope that helps you. - otherwise, feel free to ask for more detailed help!
Agent ME
I hate it when sites do that - especially since I use Firefox's tabbed browsing, so when a site tries to do that, it makes a new tab, and then resizes the whole window I use for all the tabs.
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.