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.
Printable View
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.
fraid not!
'fraid not' does this mean it cannot be done at all?
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 ......
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.
If the thread starter himself asnwers the question then I get :confused: .
Please someone explain this to ME.
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:o
Hope this explains my reason for the posting.
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!
To progressive: Any reason why you would close the screen if it did that to you?
Just wondering:)
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();">
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.
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.
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! ;)
oh yeah edit your first post and put resolved in the subject so people know the problem has been solved!!
:) No worries thanks and take care.