Results 1 to 15 of 15

Thread: (RESOLVED) Screen size and center

  1. #1

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303

    Question (RESOLVED) Screen size and center

    Using Javascript I want to be able to open my default home page with the browser screen set to a certain height, width and centered on the screen. Can this be done?

    I can open a new window and do this, but thats not what I'm after.
    Last edited by parkes; Nov 27th, 2001 at 06:50 AM.
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  2. #2
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    fraid not!

  3. #3

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    'fraid not' does this mean it cannot be done at all?
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  4. #4
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    It can't be done clientside, you might have a chance with a server side laguage, but i doubt it!

    Tyr the ASP forum it is probbaly your best bet ......

  5. #5

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    Well as we speak I tried this bit of code I wrote and it seem to do what I want, even when I just refresh or open my default page. It seems okay in IE, haven't tried it in NS or any others, but it seem to work.

    function setBrowser()
    {
    tmpWin=window.self;
    x=(795);
    y=(590);
    var t = (screen.width) ? (screen.width-x)/2 : 0;
    var l = (screen.height) ? (screen.height-y)/2 : 0;
    tmpWin.resizeTo(x,y);
    tmpWin.moveTo(t,l);
    }



    <body onLoad="setBrowser();">

    Give it a shot and let me know what you think or if it works at all for you.
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  6. #6
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    If the thread starter himself asnwers the question then I get .

    Please someone explain this to ME.

  7. #7

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    Sorry about that, I had been trying for days to get this thing to work so I posted the question, but kept trying and I was surprised to say the least that it seem to work, I've just asked anyone who reads this to see it it works okay for them

    Hope this explains my reason for the posting.
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  8. #8
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    I stand corrected, it works for me.

    works to a degree in nutscrape!

    I would however like to point out that if a site did that to my browser i'd be reaching for the cross in the corner of my browser and clicking it!

  9. #9

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    To progressive: Any reason why you would close the screen if it did that to you?

    Just wondering
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  10. #10
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    Because It's intruding on my browser, you didn't open it I did.

    I opened it and had it all nice and set out the way i like it then you come along and mess with it.

    It's my window so leave it alone!

    ...no offence but this is the view of most users so try to avoid it if possible.


    heres how you get it to work in netscape 4!
    Code:
    <script>
    function setBrowser()
    {
    tmpWin=window.self;
    x=(795);
    y=(590);
    var t = (screen.width) ? (screen.availWidth-x)/2 : 0;
    var l = (screen.height) ? (screen.availHeight-y)/2 : 0;
    if (document.all){
    	tmpWin.resizeTo(x,y);
    }else{
    	tmpWin.outerHeight = y;
    	tmpWin.outerWidth = x;
    }
    tmpWin.moveTo(t,l);
    }
    </script>
    <body onLoad="setBrowser();">

  11. #11

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    Cheers for that.

    ..No offence taken, always open to suggestions. It only going to be used to internal use anyway. Though others may like to use the code.

    Is there a way on this site to submit code like this for people to use.
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  12. #12
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    Arrow hi

    It works in IE havent tested it in Netscape.

    But I wonder why would you want to do it in the first place.

    secondly, I agree with progressive. that the main window should not be touched.

  13. #13
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    It'll be alright here people will find it by doing a search!

    Seeing as it's for internal use it'll be fine, but If you ever use on a corporate site then you better make sure your content grabs me by the eye balls and makes me go "whooaaa would you look at that" or i'll close it!

  14. #14
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    oh yeah edit your first post and put resolved in the subject so people know the problem has been solved!!

  15. #15

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    No worries thanks and take care.
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

Posting Permissions

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



Click Here to Expand Forum to Full Width