dcsimg
www.webdeveloper.com
Results 1 to 12 of 12

Thread: Another center window question

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Posts
    21

    Another center window question

    hello here's the chunk of code I need help with.


    <h3 align="center">Portrait, Beauty, Glamour and Fashion photography </h3>
    <p align="center"> <a href="#"><img src="jpg/fashionbeauty.jpg" width="513" height="132" hspace="" vspace="" border="0" onclick="MM_openBrWindow('portfoliowindow.html','fashionbeauty','scrollbars=yes,width=600,height=600 , top=-50%, left=50')"/></a></p>



    I wish to have the window that is opened, open in the exact center of the screen, from left, and top.

    Can someone provide the right help, and where to put it.

    As you can see I have been trying the wrong methods.

    i.e.

    top=-50%, left=50')"/>


    -50% is not working.

    Thank you

    H

  2. #2
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    See http://www.felgall.com/cshow03.htm for how to put something in the exact centre of the window.

  3. #3
    Join Date
    Jul 2006
    Posts
    21
    Guy... none of your answers anywhere on this site ever help. Someone always comes along and one ups you. All the time. It's because you don't read the postings before you type...

    Obviously you did not read my posting... I do not need to know how to center a table... i'm not using tables... I have pasted the code I wish to amend above... fix that your the man, post another meaningless reply, well... it is what it is.

    H

  4. #4
    Join Date
    Apr 2006
    Posts
    225
    Give this a try. I'm not sure it will work from inside the script but it is how an object is centered using css.
    onclick="MM_openBrWindow('portfoliowindow.html','fashionbeauty','scrollbars=yes','width=600','height =600' , 'top=50%', 'left=50%', 'margin_top=-300px', 'margin-left=-300px',position=absolute')"/></a></p>
    I'm not sure if the px on the end is needed, so try it with it and without it.

  5. #5
    Join Date
    Apr 2006
    Posts
    225
    Ok time up for editing so I'll just repost
    onclick="MM_openBrWindow('portfoliowindow.html','fashionbeauty','scrollbars=yes','width=600','height =600' ,'top=-50%','left=50%','margin-left=-300','margin-top=-300','position=absolute')"/></a></p>

    Make sure you always have an apostrophe in front and end of the style element

  6. #6
    Join Date
    Jul 2006
    Posts
    21
    Hi WebJoel...

    Tissues are available at modest prices in your local supermarkets, drugstores and kwiki marts....

    I'm glad Felgall has helped you out. That's terrific. I am not (obviously) replying to just this one post from him. He has generously replied to many of my posts in the past with lots of information and not very much substance. It's nice that we have access to a forum where we can all share our ideas, concepts and maybe even our dreams. I have no ill against the fellow, just wish he would read the post, before... the reply!

    Your either the ass*ole here or the newbie, i'll be the ass*ole newbie I guess and make it real easy for you, I'm here to solve my design problems not setup internet lunch dates, and I highly doubt anyone else is.... I know that someone out there (the forum users) can fix my problem in about 2 seconds... there are far more brilliant than I designers and I keep my questions short so I don't waste their time...

    So, these brilliant minds are 'up to my standards' and with great respect to them I say thank you for helping out. The ones who can't read BEFORE the reply, well, I guess they can't read...

    Well this is too long, WebJoel thanks for your insight into my ego.

    Helmut

  7. #7
    Join Date
    Jul 2006
    Posts
    21
    sticks, thank you.

    I've tried with both no px at the end at with px at the end. It now opens the new window full screen and ignores the controls (width / height).

    I am using:

    Dreamweaver
    OSX
    Safari 3

    if this means anything. Thank you.

    Helmut

  8. #8
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Sorry, misread the requirements with my earlier reply but it looked like you wanted it in the current page rather than as a new window.

    To open a window in the exact center of the screen you need to know the screen width and height and then subtract the width and height of the window to be opened and then divide by 2.

    So if you want the window to have a width and height of 600 then you want

    onclick="var w = (screen.width - 600) / 2;var h = (screen.height - 600) / 2;if (w < 0) w = 0;if (h < 0) h = 0;window.open('portfoliowindow.html','fashionbeauty','scrollbars=yes,width=600,height =600, top='+h+'px, left='+w+'px')"
    Last edited by felgall; 07-03-2007 at 10:00 PM.

  9. #9
    Join Date
    Jun 2007
    Posts
    21

    Lightbulb Great Work

    Now let's drop it in a function and never have to code it again.

    <html>
    <head>
    <script language="javascript">
    function winOpen(pagename,name,left,top,width,height,scroll,resize) {
    var w = (screen.width - width) / 2;
    var h = (screen.height - height) / 2;
    if (w < 0) w = 0;
    if (h < 0) h = 0;

    window.open(''+pagename,name,'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=1, location=0,scrollbars=0,resizable=0');

    }

    </script>
    </head>
    <body>
    <center>
    <p>
    <h3>Javascript Window Demo</h3><br>
    <input type="button" value="open window" onclick="javascript:winOpen('pagetwo.html','myWindow',100,100,300,300,1,0);">
    </p>
    </center>
    </body>
    </html>

  10. #10
    Join Date
    Jul 2006
    Posts
    21
    Thank you kindly gentlemen, I will try this out tomorrow. Much appreciated.

    Cheers
    Helmut

  11. #11
    Join Date
    Jul 2006
    Posts
    21
    Felgal, your the f*&^ing man!

    Brilliant. works flawlessly. Much appreciated.

    Cheers

    Helmut

  12. #12
    Join Date
    Dec 2005
    Location
    American, living in Toronto, ON. CANADA
    Posts
    6,746
    Guy... none of your answers anywhere ....
    Ouch! -I'm not even going to touch that one. Respect to felgall, -his posts have helped me innumerable times withmy coding projects (even if it wasn't a reply to a question I asked, I have incorporated his advice). We are very fortunate to have felgall come here. Suggestion: contact a mod. and request that the offending post be deleted. Then perhaps, someone else whom is 'up to your standards' can solve your problem for you.
    Last edited by WebJoel; 07-03-2007 at 09:45 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles