center window

Posted: 05-14-2004, 12:17 AM
Hi,

can someone tell me why this doesnt work or how to rewrite it?

<HEAD>

<script language="JavaScript">

self.moveTo(screen.availWidth * -(x - 50) / 100, screen.availHeight *
-(x - 50) / 100);

</script>


</HEAD>



The goal is that the window moves itself to the center of the screen onload.


Greetings Karlo
Reply With Quote

Responses to "center window"

The ScareCrow
Guest
Posts: n/a
 
Re: center window
Posted: 05-19-2004, 05:12 AM
What is "x", where is it's value set ?

But instead of opening the window and then moving it, why not just open it in
the middle to start with ?

See attached

Ken



function openWindow(){
var fileName, windowName, theHeight, theWidth, topPos, leftPos;
windowName = "WinName";
fileName = "FileName.cfm";
theHeight = 300;
theWidth = 300;
topPos = (screen.height/2) - (theHeight/2);
leftPos = (screen.width/2) - (theWidth/2);

window.open(fileName,windowName,"left="+leftPos+", top="+topPos+",toolbar=0,loca
tion=0,directories=0,status=0,menubar=0,scrollbars =1,resizable=1,width="+theWidt
h+",height="+theHeight);
}

Reply With Quote
wetcell
Guest
Posts: n/a
 
Re: center window
Posted: 05-27-2004, 04:23 AM
Ken, being the novice I am I've obviously set this up incorrect, as no window
is appearing.

Any suggestions would be greatly appreciated. This is what I currently have:

<script language="Javascript">
<!--
function?openWindow()
{
?????var?fileName,?windowName,?theHeight,?theWidth ,?topPos,?leftPos;
?????windowName?=?"splash";
?????fileName?=?"splash2.html";
?????theHeight?=?342;
?????theWidth?=?680;
?????topPos?=?(screen.height/2)?-?(theHeight/2);
?????leftPos?=?(screen.width/2)?-?(theWidth/2);

?????window.open(fileName,windowName,"left="+leftP os+",top="+topPos+",toolbar=0,
location=0,directories=0,status=0,menubar=0,scroll bars=1,resizable=1,width="+the
Width+",height="+theHeight);
}
//-->
</script>


Reply With Quote
The ScareCrow
Guest
Posts: n/a
 
Re: center window
Posted: 05-27-2004, 04:41 AM
There is nothing wrong with this javascript.

You need to have a link to click on to activate the function

<a href="javascript:openWindow();">Open Window</a>

Put this link in the page where you want the popup to open from

Ken

Reply With Quote
wetcell
Guest
Posts: n/a
 
Re: center window
Posted: 05-27-2004, 05:17 AM
Thanks Ken. Will this work with something like this?

<body onload="javascript:openWindow();">

I'd like the window open automatically when the page is entered.

Thanks for your help : )
Reply With Quote
The ScareCrow
Guest
Posts: n/a
 
Re: center window
Posted: 05-27-2004, 05:22 AM
Yes, that will onpen the window after the initial page has loaded. Just note that the window opened through this javascript will be on top of the other page and have the focus

Ken
Reply With Quote
wetcell
Guest
Posts: n/a
 
Re: center window
Posted: 05-27-2004, 06:13 AM
I'm not having any joy here. Sorry to be a pain. Here is the test page:

http://www.jlbgroup.com.au/index2.asp

I've tried both onload and also a link (it's in the left column)

Any ideas?
Reply With Quote
The ScareCrow
Guest
Posts: n/a
 
Re: center window
Posted: 05-27-2004, 06:18 AM
When I went to that page.

The window open automatically, the page went from white to blue to purple to
green then to white and then closed.

When I click on the link the same thing happens.

Do you have javascript enabled in your browser ?

Ken

Reply With Quote
wetcell
Guest
Posts: n/a
 
Re: center window
Posted: 05-27-2004, 07:22 AM
Oh. I'm thinking it's because I'm using an Apple. Checking this on my PC now.

Thanks very much.
Reply With Quote
wetcell
Guest
Posts: n/a
 
Re: center window
Posted: 05-27-2004, 07:29 AM
Yes it works on my windows machine!

Incase your intersted; it didn't work in IE 5.2 or Safari under OS X.
Reply With Quote
 
LinkBack Thread Tools Search this Thread Display Modes
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot center text in Contribute 2 Diane Macromedia Contribute Connection Administrtion 0 07-18-2005 08:10 PM
CFMX Plus Microsoft Application Center OwenWest Coldfusion Server Administration 1 06-01-2005 09:33 PM
center submit button Jim Wells Coldfusion Flash Integration 2 04-29-2005 02:24 PM
is it possible to center a text? rlam Macromedia Flash Data Integration 1 02-23-2005 02:42 PM
Layer problem...How do I center my opening page?? FB1976 Macromedia Dreamweaver 1 07-08-2003 06:17 PM