Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default center window

    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
    karlogaga Guest

  2. Similar Questions and Discussions

    1. Get center of users window
      Hi I have the following problem. I have a Flex application that has modal pop up windows. The Flex app has a large hight, so I can't be sure the...
    2. Child window property window.opener null after postback
      I have an webform from which I open a child window to display a calendar. When a date is selected in the calendar window it attempts to set the...
    3. How does one center a pop-up window using actionScript?
      I repeat: How does one center a pop-up window using actionScript?
    4. dlopen is failing on Window XP works great on Window 2000
      Michael Davis <mdavis@sevasoftware.com> writes: Check the permission of the so file: $ ls -l...
    5. Center in Window
      My site is fullarmorgroup.com. Obviously, my first go at it. I am changing the background to black and want it to automatically center in any browser...
  3. #2

    Default Re: center window

    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);
    }

    The ScareCrow Guest

  4. #3

    Default Re: center window

    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>


    wetcell Guest

  5. #4

    Default Re: center window

    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

    The ScareCrow Guest

  6. #5

    Default Re: center window

    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 : )
    wetcell Guest

  7. #6

    Default Re: center window

    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
    The ScareCrow Guest

  8. #7

    Default Re: center window

    I'm not having any joy here. Sorry to be a pain. Here is the test page:

    [url]http://www.jlbgroup.com.au/index2.asp[/url]

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

    Any ideas?
    wetcell Guest

  9. #8

    Default Re: center window

    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

    The ScareCrow Guest

  10. #9

    Default Re: center window

    Oh. I'm thinking it's because I'm using an Apple. Checking this on my PC now.

    Thanks very much.
    wetcell Guest

  11. #10

    Default Re: center window

    Yes it works on my windows machine!

    Incase your intersted; it didn't work in IE 5.2 or Safari under OS X.
    wetcell Guest

  12. #11

    Default Re: center window

    Change it to -

    <body onload="openWindow();">

    You don't need the javascript: there....

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver MX
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]news://forums.macromedia.com/macromedia.dreamweaver[/url] - THE BEST WAY TO GET
    ANSWERS
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================

    "wetcell" <webforumsuser@macromedia.com> wrote in message
    news:c93q3t$kh$1@forums.macromedia.com...
    > 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 : )

    Murray *TMM* Guest

  13. #12

    Default Re: center window

    Hi Ken,

    thank you very much for answering, i had given up on getting an answer
    already...
    To your first question, i dont know what the "x" is, i just copied the
    script out of a function.

    Its that i want the window to move to the center when someone types in
    the Url in a browser, not from a link.

    Since it is possible to move the window to the center, i wonder if you
    could also define something different than the center, something like
    having the left corner of the new window opening 200 pixels left from
    the center and 200 pixels higher than the center?


    Thanx and greetings Karlo





    The ScareCrow wrote:
    > 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);
    > }
    >
    karlogaga Guest

  14. #13

    Default Re: center window

    Put the attached code in the page that is to be opened in the popup window.
    Just change the values for the width and height to what ever you need.


    Ken

    <script language="JavaScript">
    <!--
    // bWidth is the width of the window
    // bHeight is the height of the widow
    var bWidth = 300;
    var bHeight = 300;
    self.moveTo((screen.width/2) - (bWidth/2), (screen.height/2) - (bHeight/2));
    //-->
    </script>

    The ScareCrow Guest

  15. #14

    Default Re: center window

    Hi Ken, this rocks, thank you very much!

    Karlo




    The ScareCrow wrote:
    > Put the attached code in the page that is to be opened in the popup window.
    > Just change the values for the width and height to what ever you need.
    >
    >
    > Ken
    >
    > <script language="JavaScript">
    > <!--
    > // bWidth is the width of the window
    > // bHeight is the height of the widow
    > var bWidth = 300;
    > var bHeight = 300;
    > self.moveTo((screen.width/2) - (bWidth/2), (screen.height/2) - (bHeight/2));
    > //-->
    > </script>
    >
    karlogaga Guest

  16. #15

    Default Re: center window

    looks good... worked for me

    --
    ---
    Best Regards,
    Jeremy Cowan
    edmforsale At tsgn dot net

    "karlogaga" <karlogaga@yahoo.com> wrote in message
    news:c96rbc$o5m$05$1@news.t-online.com...
    > Hi Ken, this rocks, thank you very much!
    >
    > Karlo
    >
    >
    >
    >
    > The ScareCrow wrote:
    > > Put the attached code in the page that is to be opened in the popup
    window.
    > > Just change the values for the width and height to what ever you need.
    > >
    > >
    > > Ken
    > >
    > > <script language="JavaScript">
    > > <!--
    > > // bWidth is the width of the window
    > > // bHeight is the height of the widow
    > > var bWidth = 300;
    > > var bHeight = 300;
    > > self.moveTo((screen.width/2) - (bWidth/2), (screen.height/2) -
    (bHeight/2));
    > > //-->
    > > </script>
    > >

    simsghost aka TSGN.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139