whoops change it to this:
if(document.location.searc
newwin=window.open(documen
self.close()
}
Main Topics
Browse All TopicsAs you might guess from the question title, I would appreciate someone showing me how to get a browser window to
- load to a specified size
- at a specified position
- have no toolbars
- no scrollbars
-no address bar
I don't want this to be done from onClick of another page. It has to be onload of this page.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
whoops change it to this:
if(document.location.searc
newwin=window.open(documen
self.close()
}
I'm sorry, but I'm a little bit confused right now. Do you want to
-*- open a new window with specific properties(no toolbars, scrollbars, etc.) from a parent window and keep the parent window
-*- open the parent page in a new window with properties and close the original window, thereby making the page appear to load with those properties
-*- open the parent page in a new window with properties and DON'T close the original window
-*- do something else
Ok, no problem, just use this:
function openWin() {
url = "mypage2.html" //Set address of new window
var height = 400 //Set height
var width = 400 //Set width
var name = "winname" //Set window name
var top = 20 //Set distance from top
var left = 20 //Set distance from bottom
newwin=window.open(url, name, "fullscreen=no,toolbar=no,
}
Hope that works for you ;-) !
{Slam}
I like this idea*, and I'm trying to use it for home web pages, but the one problem I'm having which I'm wondering if it could be resolved is, whenever I load my initial page, IE keeps mentioning that the page is trying to close itself, and it asks if I wish to 'OK' this or 'Cancel' it. It would be nice if I could either answer the question in the coding so I don't have to interact with the question.
The otherway it would be nice to have this work would be upon initial loading of the page, there should be no toolbar, scrollbar, etc..., not load a page with everything to begin with then load another page without all the above mentioned and then close the initial page.
Is there a way to do this?
*Script mentioned above.
<script type='text/javascript'>
var height = 400 //Set height
var width = 400 //Set width
var name = "winname" //Set window name
var top = 20 //Set distance from top
var left = 20 //Set distance from bottom
if(document.location.searc
newwin=window.open(documen
self.close()
}
</script>
Some answers:
*enigmafyv -- The problem of the automatic IE prompt was solved in the original answer, however it was edited out by the mplungjan because it involves a slight hack. If you want the entire script, e-mail me at superslamwich@yahoo.com
*djtep -- Sorry, but it's impossible. The only way to control the toolbars, status bar, etc. of a window is to open it yourself. Again, if you want the full script, e-mail me.
{Slam}
Usually whenever an html page opened directly (without javascript) is closed using javascript, ie prompts for confirmation (OK / Cancel). There is a workaround for this. just change 'self.close();' to 'self.parent=self; self.parent.close();' The code snippet from above is used to show this. Please see the last 2 lines.
<script type='text/javascript'>
var height = 400 //Set height
var width = 400 //Set width
var name = "winname" //Set window name
var top = 20 //Set distance from top
var left = 20 //Set distance from bottom
if(document.location.searc
newwin=window.open(documen
self.parent = self;
self.parent.close()
}
</script>
Yeah, don't ask me. I don't know why it's considered a hack, I just know I've posted that answer a couple of times and the admins removed it on grounds that it "contained a browser hack". :-D I don't see what the problem of setting a browser window as it's own parent is a hack. Maybe it's considered a hack just because it bypasses the standard IE message box that tells you "A program is trying to close this window, do you want to close it?". Again, don't ask me. I've used it in the past and will continue to do so if I need to close an IE window automatically for some logical, rational reason.
Redefined is right. Microsoft calls things like this "extending" (i.ie. extending a class or adding to the capabilities of an incomplete model), but here it is known as a "hack". Nice.
I thought the purpose of this site, to make our jobs less difficult. I could understand an out and out "hack" where you are exposing a literal weakness of software, but not something to extend the user friendliness of an application. If a visitor had to click to close the window everytime, or a more amatuer visitor didn't know what to do at that point, we lose at least a step in ensuring the ease of the application (i.e. stripping uneccessary steps by the visitor) and perhaps lose a potential client (a.k.a. customer service).
If you ask me, the whole" closing window confirmation" is a built-in flaw of Internet "Exploder" anyway. Personally, I only use it at work because I have to.
I completely understand the ruling to censor or disallow such "hacks", but isn't this one at least in a grey area, and not an actual hack? Hopefully, these items which are more of a grey area are not destined to only be available by e-mailing the wonderful experts we have here. We once again would lose at least a step of user-friendliness.
Here's a quick thank you to the experts here... THANK YOU!
Place the above code in a function, and then call it on the onload attribute of the body tag:
<script type='text/javascript'>
function SetWindow()
{
var height = 400 //Set height
var width = 400 //Set width
var name = "winname" //Set window name
var top = 20 //Set distance from top
var left = 20 //Set distance from bottom
if(document.location.searc
newwin=window.open(documen
self.parent = self;
self.parent.close()
}
}
</script>
<body onload="SetWindow();">
Ya, hismightiness is right, you have absolutely no control whatsoever over the current window in terms of status bar, toolbars, etc. If you want to know the truth, it's probably better that way, it's best not to fool too much with a user's main browser window as it can seriously tick some people off.
{Slam}
I think that disallowing the window to be set and allowing the popup window to have these attibutes set, offers the user no improvement on the experience. When the smoke and dust settles, the browser displayed is modified. So to suggest that one should not "foo" with the main browser does not seem to me to make a whole lot of sense. After all (slam), the point of this question is how to make the browser appear in a "fooled with" way to begin with (hismightiness might want to reconsider suggesting that my question is outside this scope as it really is not). As to the main browser window (slam), I run windows, and it allows multiple "main" browsers, so you've lost me again on that one.
By the way, the code : self.parent = self; self.parent.close() does not seem to work for me and the IDE issues the error "Not Implemented" on these lines of javascript.
hbash, I was not suggesting that your question was outside the scope of this "topic". However, this is not your typical forum web site. This site survives on the premise of rewarding and "buying" expert advice and help, hence the point system... By posing your question under a topic where the help was already awarded, it defeats the purpose of the site in general. It is kind of like driving a motorcycle in a lake, it just doesn't work that way. Please don't take offense, I just know that many of the "experts" here do indeed take offense because they often put a lot of time and effort into helping all of us here.
Try using the following adjustment to the code though...
// Cannot perform across all browsers
this.focus();
*** hack removed, mplungjan, ee page editor ***
self.close();
I live in IE for the most part, as do probably most PCs out there, so this is fine. I have previously had some major bad times with Netscape, so I don't really program for it. My .NET code even works on the MAC IE Browser, so why look elsewhere.
Again though, I would love to pass you the points for this one. Any suggestions on how to do so?
Thanks Again (no you're welcome required, I appreciate the effort alot),
Howard
hbash: the "main" browser window is the one whoever is on the computer is using at the time. By taking away any control the user has over this window, the one they are looking at, you are very likely going to tick some people off. You may go ahead and do it by all means, this is why I provided an answer to the question, however my opinion is that in general it's not a good first impression to make on a user. But again, like I said, it's your choice.
{Slam}
Hi.
I'm a total gimp when it comes to scripting. I want to use the above code as well, I tried to just paste it in to my document head and put the onLoad part in the body. It does not work for me however. Where does the code go? Does the script tag need to change? How does it now what window to open?
Like I said I know nothing and would really appreciate a straightforward explanation and copy/paste script.
Cheers.
UPDATE:
I have a version that takes into account Pop-up blockers and non-IE browsers. If the script CAN be executed, it will be, otherwise nothing will happen and you'll still have the original browser window. Since EE doesn't want this posted here(the hack thing), e-mail me at sborchard at sps.edu to get the code.
{Slam}
RE: Comment from djtep
Date: 07/20/2004 07:04AM PDT
Comment
Hi.
I would like to know how to *remove* toolbars, status bar, menu bar, etc from the *current* HTML page. I do not want to open a new window to achieve this effect.
Regards,
Jason
--------------------------
I've been working on this problem for a while and finally came up with a work around for Netscape 4+, but not IE.
The user is still asked to accept the changes that are going to be made to their browser so I don't think that it will tikc too many people off.
Please feel free to use it. I plan to continue until I find a work around for IE and will post when I find one:
<script language="javascript" type="text/javascript">
function loadPage() //remove toolbars, status bar, menu bar, etc and resize window
{
netscape.security.Privileg
window.menubar.visible = false;
window.locationbar.visible
window.scrollbars.visible = false;
window.personalbar.visible
window.statusbar.visible = false;
window.toolbar.visible = false;
netscape.security.Privileg
resizeTo(width,height); //replace with actual numerical values
}
</script>
hope this helps. please email me with feed back: xombierx at yahoo dot com
Thats quite cool xombierx. Not actually having Netscape with me at the moment, I can't test your code, but I'll take your word for it until I have a chance to test it myself. I'll add this to the script
Just one question, is the loadPage() function done onLoad, or can it just be called in the head?
Seeing as EE doesn't appear to be censoring this anymore, I'm gonna relieve some stress on my inbox and just paste the full code here, complete with the script from xombierx
*** Yes we are, when we see it ***
<script type='text/javascript'>
<!--
var appVer = navigator.appVersion.toLow
if(appVer.indexOf('msie'))
{
var height = 400 //Set height
var width = 400 //Set width
var name = "winname" //Set window name
var top = 20 //Set distance from top
var left = 20 //Set distance from left
if(document.location.searc
window.open(document.locat
// *** hack removed, page editor ***
// self.close()
} else
{
window.opener.close();
}
} else {
netscape.security.Privileg
window.menubar.visible = false;
window.locationbar.visible
window.scrollbars.visible = false;
window.personalbar.visible
window.statusbar.visible = false;
window.toolbar.visible = false;
netscape.security.Privileg
resizeTo(width,height); //replace with actual numerical values
}
//-->
</script>
If I'm not using the Netscape thing right just tell me or fix it and paste it.
{Slam}
Slam,
I had a question about the assignment and comparrison at the begining of the script:
var appVer = navigator.appVersion.toLow
if(appVer.indexOf('msie'))
navagator.appVersion returns an int, why do you try to lowercase it? and how does appVer, which should be an int become a string? also, appVersion only works in NN:2 and IE:3
anyhoo, I revised your script to use browser detection to determine which method to use for loading the page. This script assumes that the script that superslamwich wrote works for all browsers besides Netscape/Mozill. (I have tested it with IE:6 and Firefox 1.0 (NN:5)
<script type='text/javascript'>
<!--
var height = 400 //Set height
var width = 400 //Set width
var name = "winname" //Set window name
var top = 20 //Set distance from top
var left = 20 //Set distance from left
//script revision by A. Kuehler, XombieRx
if(navigator.appName == "Netscape") //start handling for Netsacpe and Mozilla
{
netscape.security.Privileg
window.menubar.visible = false;
window.locationbar.visible
window.scrollbars.visible = false;
window.personalbar.visible
window.statusbar.visible = false;
window.toolbar.visible = false;
netscape.security.Privileg
resizeTo(width,height); //replace with actual numerical values
}//end if handling for Netscape/Mozilla
else
{ //for all other browers
//script provided by superslamwich
if(document.location.searc
{
window.open(document.locat
// *** hack removed ***
// self.close()
}
else
{
window.opener.close();
}
}//end handling for all other browsers
//-->
</script>
cheers, again if you have any questions or comments please email me xombierx at yahoo dot com
Hi gang, I'm new to EE and sure am glad I found this thread! Great solutions!
I'm working on a little in-house web app to accomodate both desktop & tablet PC users. I'm in the same boat as hbash (above), and found superslamwich's & hismightiness' examples to work GREAT. Although, I have a wrinkle in the scenario that you may be able to help me iron out...
Here's the objective:
User loads Page A (ordinary window)
- Link in Page A opens Page B
Page B (window with specified "Desktop" properties)
- Page B uses slam's script and hismightiness' addendum in a function I've labeled "SetWindow_DesktopMode" to set window size, position, attributes... (see function below)
- Link in Page B opens Page C
Page C (window with specified "Tablet" properties)
- Page C uses the same function with different params, labeled "SetWindow_TabletMode"
The desired effect: if the user clicks the "View in Tablet Mode" link on Page B, the browser loads Page C (which has different content and CSS) and resizes the window accordingly.
Using the SetWindow_DesktopMode function works perfect going from Page A to Page B. However, when going from Page B to Page C, the window simply disappears!
FUNCTION USED IN PAGE B
<SCRIPT LANGUAGE="JavaScript">
function SetWindow_DesktopMode()
{
var height = 700 //Set height
var width = 758 //Set width
var name = "winname" //Set window name
var top = 0 //Set distance from top
var left = 0 //Set distance from left
if(document.location.searc
newwin=window.open(documen
this.focus();
// *** hack removed ***
self.close();
}
}
</SCRIPT>
<BODY onload="SetWindow_DesktopM
FUNCTION USED IN PAGE C
<SCRIPT LANGUAGE="JavaScript">
function SetWindow_TabletMode()
{
var height = 955 //Set height
var width = 758 //Set width
var name = "winname" //Set window name
var top = 0 //Set distance from top
var left = 0 //Set distance from left
if(document.location.searc
newwin=window.open(documen
this.focus();
// *** hack removed again and again ***
self.close();
}
}
</SCRIPT>
<BODY onload="SetWindow_TabletMo
...anybody willing to steer me in the right direction?
Thanks,
-s_ferguson
These are the standards to the best of my knowledge.
I believe this post will answer all of your questions.
<!-- Current window //-->
Method (Mozilla):
window.[element].visible=[
Attributes (Mozilla):
menubar, directories,
statusbar, toolbar,
locationbar, personalbar,
scrollbars
Method(Internet Explorer):
scroll="[Value]"
Method(Cross Browser);
parent.resizeTo(width,heig
Example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyDoc</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!-- Resize Cross Browser //-->
parent.resizeTo(50,50);
<!-- End Resize Cross Browser //--<
<!-- No Scroll Mozilla //-->
window.scrollbars.visible=
<!-- End No Scroll Mozilla //-->
</script>
</head>
<!-- No Scroll Internet Explorer //-->
<body scroll="no">
<!-- End No Scroll Internet Explorer //-->
</body>
</html>
<!-- New Window Internet Explorer //-->
Method:
window.open('URL', 'Name', 'Arguments');
Arguments:
width, height, toolbar,
location, directories, status,
scrollbars, resizable, menubar.
Example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyDoc</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!-- Open New Window //-->
window.open('YourPage.html
<!-- End Open New Window //-->
<!-- Close Current Window //-->
window.close();
<!-- End Close Current Window //-->
</script>
</head>
<body></body>
</html>
If you find any problems with my code, please let me know.
I would also be happy to answer any questions you may have.
You may contact me via email at either of the following addresses:
*email address removed*
I believe that you can only disable the location bar, status bar, menu bar, etc. if you request universal browser write privileges. This prompts the user to accept the changes that you are going to make to their browser window. I don't think that NN's interpreter allows you to alter the state of the window without the user's permission.
I've included this in my script above by using the lines
netscape.security.Privileg
//alter the state of the window here
netscape.security.Privileg
I am unable to make your script work for your arguments under NN5 and i believe that this is the issue.
Firstly XombieRx, I would like to thank you for replying to my post. This is my first time posting on this message board and you are the first to reply to my post.
Yes, you are correct. My intention was to provide simple, clean and easily understood code. You and others have already provided the code in question in previous posts, with more complex examples of its use. Because of this coupled with the fact that the code in question is not required in Firefox, I saw very little reason to include it in my post. However in the interests of backwards compatability, a user may choose to include it in their script.
***IMPORTANT***
I have received many questions regarding this, so in hope of pre-empting further inquiries:
The script above by XombierX(Date 01/03/2005) exploits a loophole found ONLY in Internet Explorer. The code will work with other browsers, however they WILL ASK THE USER FOR PERMISSION. There is no way around this. Also if a pop-up blocker is in use the page will be displayed with toolbars.
Also, this script will override all tabs in the active window in Firefox, and (though I haven't checked) possibly other tabbed browsers.
THERE IS NO WAY TO STOP ANY OF THIS FROM HAPPENING
After looking at all the complications, I would suggest NOT using the script, as it's results are hardly predictable, and it creates problems in some browsers. If you really need a window with no toolbars, call it onClick from another page, otherwise just leave the window with the toolbars.
Thank you
{Slam}
Business Accounts
Answer for Membership
by: superslamwichPosted on 2003-10-20 at 16:47:54ID: 9587225
<script type='text/javascript'>
h=='') { t.location + "?newwin=true", name, "fullscreen=no,toolbar=no, status=no, menubar=no ,scrollbar s=no,resiz able=no,di rectories= no,locatio n=no,width =" + width + ",height=" + height + ",left=" + left + ",top=" + top)
var height = 400 //Set height
var width = 400 //Set width
var name = "winname" //Set window name
var top = 20 //Set distance from top
var left = 20 //Set distance from bottom
if(document.location.searc
newwin=window.open(documen
}
</script>