Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Size windows? 1

Status
Not open for further replies.

un1k

Technical User
Mar 8, 2004
30
0
0
CA
Hi I am wondering how to automatically size a window on the load. For example I want my first page (index.htm) loads at 640x480. Is there a way to do this in HTML? If no, in JavaScript? thanks!
 
un1k,

You can use javascript to perform this action:

Code:
<body onLoad="window.resizeTo([blue]<width>[/blue], [blue]<height>[/blue]);">

This will work on current the current window. If you want to use a hyperlink to open a window to a certain size then you could use this code:

Code:
<A HREF='javascript:void(0)' onClick="window.open('index.html','NewWindow','width=[blue]<width>[/blue],height=[blue]<height>[/blue]');">Open new window</A>

Hope this helps.
-Ron

P.S. Be sure to replace the blue tags with the appropriate numbers.

We all play from the same deck of cards, it's how we play the hand we are dealt which makes us who we are. -Me

murof siht edisni kcuts m'I - PLEH
 
Sorry it's me again, how do I add the toolbar=no and other commands like that into the code?
 
try this
Code:
<script language="javascript">
function newWin(oUrl) {
window.open(oUrl,'name','width=500,height=400,resizable=no,scrollbars=no,menu=no,status=no');
}
</script>


buffalo.gif

 
That's not working do I have to replace something in there?
 
[tt]I hope you just didn't copy and paste.

Post your code inside the [ignore]
Code:
[/ignore]
tags to see how you're using the code.
[/tt]


buffalo.gif

 
Well thats what I don't understand... I mean I want my index.html automatically load at the specific size and no toolbars and that stuff... so with the code you gave me, do I have to replace something... sorry I'm not to advanced :eek: Thanks for taking the time to help me

Code:
<HTML>

<HEAD>
<script language="javascript">
function newWin(oUrl) {
window.open(oUrl,'index.htm','width=500,height=400,resizable=no,scrollbars=no,menu=no,status=no');
}
</script>


<TITLE></TITLE>

</HEAD>

<BODY>
<img src=index.jpg>

</BODY>

</HTML>
 
I suppose it would be appropriate at this time to ask how you want this to work. Do you want to create a hyperlink that opens a new window to a specific size, or do you want the CURRENT window to resize when a user visits a certain page?

Your code (above) will not do anything. DeCojute gave you a javascript function which you are not calling in your webpage.

So what, exactly, do you want to do?

-Ron

We all play from the same deck of cards, it's how we play the hand we are dealt which makes us who we are. -Me

murof siht edisni kcuts m'I - PLEH
 
Try this


Code:
<A HREF='javascript:void(0)' onClick="window.open('index.html','NewWindow','width=<width>,height=<height> width=500,height=400,resizable=no,scrollbars=no,menu=no,status=no');">Open new window</A>
 
Of course you would remove the first set of "Width=<width>,height=<height>" values
 
Well what I want, exactly, to do...:)

I want the CURRENT window to resize automatically, with the possibility of saying no toolbar and those options. It's like the first code you gave me :

Code:
<body onLoad="window.resizeTo(<width>, <height>);">

That code worked good, the only thing is I dunno how to add the toolbar=no, etc in that code.

Sorry if we having a hard time here, and again thanks for your help.
 
I'd like to put my 2 cents in here, and it's just my opinion. If you take away the normal functionality of a browser, users tend to shy away from your site. I, for example, want my browser to be full screen (1024x768) and I want my tool bars to be accessible at all times. 640x480 is extremely small by todays standards and makes it difficult for a lot of users to even read the text. On my screen, 640x480 is easliy confused for a pop-up. So please, if you're set on a smaller screen, please don't take away tool bars.

Just my opinion....

There's always a better way. The fun is trying to find it!
 
un1k,

Oh, sooooo close! Sorry, but "window.resizeto()" does not provide that functionality. If you need to make the toolbars disappear then you may need to rethink your design to possibly incorporate the functions of "window.open()" instead.

IMHO, unless you are dealing with an Intranet situation, I agree with tviman on this one. Most users will simply avoid your site if you change the size their MAIN window when they visit. A slightly less intrusive thing you could do would be to use the "window.open()" function in the "body onload" event:

Code:
<body onload="window.open('index.html','NewWindow',' width=500,height=400,resizable=no,scrollbars=no,menu=no,status=no');">
This would open a NEW window which you would have more control over. Many users would also find this annoying, but you'll be more likely to get away with this than resizing their main window.

Of course, all bets are off when it comes to an intranet. If your boss wants it a certain way, and employees will NEED to use it, then they won't have a choice.

-Ron

P.S. Of course there will be many users out there who won't be able to use your site if you use javascript. They include people who turn off javascript, and users of older browsers and text browsers (for visually impaired). Also, search engine spiders won't crawl javascript. So, if your site uses all javascript navigation, then you won't get crawled. This might cause you to not be highly ranked or even listed at all on some search engines. So, don't exclusively use javascript navigation. Always have some other way to navigate (even if it's only for backup)!

We all play from the same deck of cards, it's how we play the hand we are dealt which makes us who we are. -Me

murof siht edisni kcuts m'I - PLEH
 
Allright, thanks for the help and tips guys.
 
Ok, I'm a little frazzled on this. I've seen folks asking about this at many different sites yet the answers graze the solution. Surely there is a guru that knows how to initially load an Internet Explorer app w/o toolbars menubar (just the page itself can be seen). NOT a java window.open (this misses the mark because once the toolbars are available a user can start tinkering with options managers don't want them tinking around in. I'm just beside myself why instead of thinking of a solution instead a discussion starts on why you don't want to do that. The POINT I'm betting this person and myself is stating we have a VALID management standpoint to block ALL functionality of the browser to only show the page because the pc is for only that use! I wish they didn't have to use IE because it is very hard to lock down with so many grp policies to review and restricting privileges. I know I bet you'd hate to be a user at our company! he, he. Total cost of ownership doesn't suffer this way though.
 
Hello:

Help please! I need to write a link to a page and popup a 550 x 350 window for an html page. I can not place anything in the <HEAD> portion of the HTML page since it is templated.

I need a self-contained popup solution that will popup the page sized 550 x 350 and is a complete stand-alone html/script solution that can go into the <BODY> portion of my launch-from page.

Please provide a working example if you can.

Thank you.

John

John Kolker
Programmer
jwkolker@comcast.net
 
dsmith1180

The point is that the tool your users are using (Internet Explorer) is a web browser. It has certain functionality. To strip the browser of that functionality is at best an easily by passable hack and at worst a severe impediment to your users.
If you are concerned about users not being able to use the browser to do anything other than view your site/page then perhaps this isn't the best way to do it.
How about a custom application?
How about removing access to the outside world?
The reason the discussion arises is precisely because what is trying to be achieved is not necessarily the right way to solve the problem to a level that will satisfy your requirements. The posters that cry out against removing this functionality do so because they believe that it should not be done.
The question was asking how to turn off the menus on a browser window, this isn't the same as asking "I need to stop my users from being able to view anything except my site". I am sure you will agree, had this question been asked then a different discussion would arise.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top