Question

<body onload=resize window, position, no toolbars, no scrollbars

Asked by: champ_010

As 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

*** NOTICE FROM THE PAGE EDITOR:
    This question contained a lot of references to an IE hack that 
    overrides the "A script is trying to close this window" alert
    I have removed all references to it since it IS considered a hack 
    and should not be spread for unscrupulous people to close your main
    browser window without your consent !!! 
    EE page editor ***
                                  
1:
2:
3:
4:
5:
6:
7:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2003-10-20 at 16:26:44ID20772577
Tags

window

,

resize

,

onload

Topic

JavaScript

Participating Experts
14
Points
80
Comments
50

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

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.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

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.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

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.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Problem with onload event...
    Hello, I'm not sure if this would necessarily be the best place to ask this question but here goes. :-) I am working with some include files that are called by some various pages. My problem is that I only have access to the include files and not the pages but want to use...
  2. How to remove the toolbars, scrollbar, location bar in sa…
    You know how you can use the Window.Open feature to set parameters for the window you are opening (like whether or not the scrollbar appears, toolbar appears, location bar appears, etc.)? Well, I want to be able to do it as an onLoad so that, when someone comes to the web pa...
  3. HTML onload show no toolbars, no scrollbars etc
    I have built a simple contact form in Flash 5 (variables sent via FormMail script). When user sends an email they are redirected to a (thankyou, your email has been sent) HTML page. I would like the (thankyou) html page to load with no toolbars, no scroll bars, no address b...
  4. resize window onload to be "chromeless"....
    I am currently using the following code to resize my page onload <script language="JavaScript"> <!-- window.resizeTo(930,800); //--> </script> What I would like to have is it load the window with no scrollbars, toolbars, or link box.... is that...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

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.

Join the Community

Answers

 

by: superslamwichPosted on 2003-10-20 at 16:47:54ID: 9587225

<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.search=='')  {
  newwin=window.open(document.location + "?newwin=true", name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top)
}

</script>

 

by: superslamwichPosted on 2003-10-20 at 16:49:23ID: 9587233

whoops change it to this:

if(document.location.search=='')  {
 newwin=window.open(document.location + "?newwin=true", name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
 self.close()
}

 

by: superslamwichPosted on 2003-10-20 at 16:51:21ID: 9587244

*** Window close hack removed by mplungjan, EE page editor ***

 

by: champ_010Posted on 2003-10-20 at 17:29:47ID: 9587387


thanks--but my main window underneath it closed.  the window opens when my main window runs
a Coldfusion: <cflocation url="oopUp.htm">

is there any way to make the main window stay regardless wheter this one opens or closes?

 

by: superslamwichPosted on 2003-10-21 at 10:46:20ID: 9592388

just remove the "self.close()" from the function and the original window (with toolbars, etc.) will stay as well as opening another window (without the toolbars).

 

by: champ_010Posted on 2003-10-22 at 16:31:39ID: 9603097

the parent window remains open, but has changed to show the same page as the pop up.  i would like it not to change...

 

by: superslamwichPosted on 2003-10-23 at 14:52:56ID: 9610591

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

 

by: champ_010Posted on 2003-10-25 at 10:06:20ID: 9620070


hi, i'd like to:

-*-  open a new window with specific properties(no toolbars, scrollbars, etc.) from a parent window and keep the parent window

what i get right now is the second item you have above. i'm trying to get the first one happening...

thanks.

 

by: superslamwichPosted on 2003-10-25 at 14:45:18ID: 9620761

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,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
}

Hope that works for you ;-) !

{Slam}

 

by: enigmafyvPosted on 2004-04-26 at 13:12:38ID: 10922109

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.search=='')  {
  newwin=window.open(document.location + "?newwin=true", name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
 self.close()
}

</script>

 

by: djtepPosted on 2004-07-20 at 07:04:12ID: 11592943

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

 

by: broozaPosted on 2004-07-28 at 12:37:26ID: 11660662

Thanks,

I was having a similar problem, and that's helped tremendously

brooza

 

by: hismightinessPosted on 2004-08-13 at 06:21:46ID: 11792614

What a great JS!!!  This is good stuff, superslamwich...

 

by: superslamwichPosted on 2004-08-20 at 16:17:18ID: 11856865

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}

 

by: EldoPosted on 2004-08-24 at 02:31:36ID: 11879431

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.search=='')  {
  newwin=window.open(document.location + "?newwin=true", name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
  self.parent = self;
  self.parent.close()
}
</script>

 

by: itzkakarotPosted on 2004-08-24 at 14:46:42ID: 11887317

LOL, Eldo.  Sorry, but your answer is going to be edited out by the admins, as several others' were.  That answer has been provided already by a couple of people, but it's technically considered a hack so they don't allow it to be displayed here. :-/

 

by: hbojorquezgeekPosted on 2004-08-26 at 17:58:26ID: 11908909

"technically considered a hack" ?
Jeezzum...half of everything EVER done by ANY CS person is a hack.
What kind of BS censorship is that?

 

by: itzkakarotPosted on 2004-08-27 at 12:14:08ID: 11916623

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.

 

by: EldoPosted on 2004-08-28 at 22:49:06ID: 11924519

Agreeing with the comments. Well, it looks like the word 'HACK' needs to be redefined. lol.

 

by: hismightinessPosted on 2004-08-29 at 09:29:57ID: 11926188

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!

 

by: hbashPosted on 2004-08-31 at 23:05:58ID: 11949422

This all well and good.  But how do you call a javascript routine to set these properties on an onload event of a web form?

 

by: hismightinessPosted on 2004-09-01 at 05:30:59ID: 11951535

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.search=='')  {
       newwin=window.open(document.location + "?newwin=true", name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
       self.parent = self;
       self.parent.close()
     }
}
</script>

<body onload="SetWindow();">

 

by: hbashPosted on 2004-09-01 at 07:56:16ID: 11953232

This only works if you a want to launch a second window.  Using this code as presented would involve at least two window.  I am looking to modify the window as it loads (in the onload event), not load it a second time and close the first.

 

by: hismightinessPosted on 2004-09-01 at 09:59:30ID: 11955110

You should probably start this as a new question, since that is the point of this site.  However, without performing an "actual" hack, I don't think you can do what you are looking for.  That has to be done on a new window.  It is by design with nearly all web browsers, I believe.

 

by: superslamwichPosted on 2004-09-01 at 18:51:35ID: 11959571

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}

 

by: superslamwichPosted on 2004-09-13 at 16:35:23ID: 12049836

BTW, e-mail change for the question, you can now reach me at:    sborchard    at     sps.edu

 

by: hbashPosted on 2004-09-13 at 21:13:36ID: 12051244

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.



 

by: hismightinessPosted on 2004-09-14 at 04:50:16ID: 12053297

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();

 

by: hbashPosted on 2004-09-14 at 11:57:39ID: 12058244

hismightiness,  

That did it.  The page displays and I do not get the msg asking to allow IE to close.  Excellent!!!  How can I get send you points?  I could create a question for you to answer (anything at all really),  and then give you the points that way.

Thanks!!!!!!!!!!!!!!!!!!!!!!!
Howard

 

by: hismightinessPosted on 2004-09-14 at 12:07:43ID: 12058344

That what some people do.  They just open a question stating something like "points for [name]".  If you do decide to do that, let me know so I don't let it sit there to go to waste.  :)

About the code...  I have only tested that code on IE, Mozilla, and Netscape.  It only works in IE so far.

 

by: hismightinessPosted on 2004-09-14 at 12:09:18ID: 12058364

Oops...  Forgot the customary "you're welcome".  Hehehe...  You are welcome.  :D

 

by: hbashPosted on 2004-09-14 at 13:11:43ID: 12058926


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

 

by: hismightinessPosted on 2004-09-14 at 13:41:17ID: 12059164

You can do either one of two things...  Either open a new question for whatever amount of points, and have the subject/text say "Points for Hismightiness", or go to the customer service area and request to award points to me.  Either way would work.  Have a great day!

 

by: hbashPosted on 2004-09-14 at 13:54:26ID: 12059269

To make sure it happens,  I will go to the customer service area and make the request that way.

Take Care!

 

by: superslamwichPosted on 2004-09-14 at 14:44:29ID: 12059641

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}

 

by: iamcmagPosted on 2004-11-24 at 15:57:22ID: 12670872

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.

 

by: hismightinessPosted on 2004-11-25 at 05:36:44ID: 12674515

iamcmag,

You need to put this in a new question showing your code, the line givng the error, and a thorough description of the error.

 

by: superslamwichPosted on 2004-11-25 at 18:27:52ID: 12678212

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}

 

by: XombieRxPosted on 2004-12-27 at 22:27:36ID: 12910843

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.PrivilegeManager.enablePrivilege("UniversalBrowserWrite")
      window.menubar.visible = false;
      window.locationbar.visible = false;
      window.scrollbars.visible = false;
      window.personalbar.visible = false;
      window.statusbar.visible = false;
      window.toolbar.visible = false;
      netscape.security.PrivilegeManager.revertPrivilege("UniversalBrowserWrite")
      resizeTo(width,height);   //replace with actual numerical values
}
</script>


hope this helps. please email me with feed back:   xombierx  at    yahoo dot  com

 

by: superslamwichPosted on 2005-01-03 at 06:49:07ID: 12943853

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.toLowerCase();
  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.search=='')  {
    window.open(document.location + "?newwin=true",name,"fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
    // *** hack removed, page editor ***
//    self.close()
  } else
  {
    window.opener.close();
  }
} else {
  netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite")
  window.menubar.visible = false;
  window.locationbar.visible = false;
  window.scrollbars.visible = false;
  window.personalbar.visible = false;
  window.statusbar.visible = false;
  window.toolbar.visible = false;
  netscape.security.PrivilegeManager.revertPrivilege("UniversalBrowserWrite")
  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}

 

by: XombieRxPosted on 2005-01-03 at 08:45:25ID: 12944724

Slam,

I had a question about the assignment and comparrison at the begining of the script:

  var appVer = navigator.appVersion.toLowerCase();
  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.PrivilegeManager.enablePrivilege("UniversalBrowserWrite")
  window.menubar.visible = false;
  window.locationbar.visible = false;
  window.scrollbars.visible = false;
  window.personalbar.visible = false;
  window.statusbar.visible = false;
  window.toolbar.visible = false;
  netscape.security.PrivilegeManager.revertPrivilege("UniversalBrowserWrite")
  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.search=='')  
      {
      window.open(document.location + "?newwin=true",name,"fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
//      *** 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

 

by: superslamwichPosted on 2005-01-03 at 17:07:13ID: 12948872

To be honest, I was a little lazy and just looked around for a browser ID script and that's what I found.  It worked fine with IE, but I didn't test it in Netscape because I don't have it.

Thanks for correcting the error.

{Slam}

 

by: s_fergusonPosted on 2005-02-02 at 13:26:35ID: 13208173

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.search=='')  {
                   newwin=window.open(document.location + "?newwin=true", name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=yes,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
      
                        this.focus();
                        // *** hack removed ***
                        self.close();
                  
                        }      
                  }
            </SCRIPT>


<BODY onload="SetWindow_DesktopMode();">


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.search=='')  {
                   newwin=window.open(document.location + "?newwin=true", name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=yes,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
      
                        this.focus();
                        // *** hack removed again and again ***
                        self.close();
                  
                        }      
                  }
            </SCRIPT>


<BODY onload="SetWindow_TabletMode();">


...anybody willing to steer me in the right direction?

Thanks,
-s_ferguson

 

by: superslamwichPosted on 2005-02-02 at 17:57:42ID: 13210160

Change the window name in page C.  It's opening the "new" window in the same window.

So instead of
                var name = "winname"                  //Set window name
make it
                var name = "winname2"                  //Set window name

or something else

{Slam}

 

by: s_fergusonPosted on 2005-02-02 at 19:13:29ID: 13210469

Nice!  I knew it was something I was overlooking, but I'm just deep enough into the "woods" (JavaScript territory) to begin loosing my way ; -)

Slam, thanks for the quick response!

Best,
s_ferguson

 

by: StuperfiedPosted on 2005-02-25 at 19:39:19ID: 13408866

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=[Value];

Attributes (Mozilla):
menubar, directories,
statusbar, toolbar,
locationbar, personalbar,
scrollbars

Method(Internet Explorer):
scroll="[Value]"

Method(Cross Browser);
parent.resizeTo(width,height);

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=false;
<!-- 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', 'Window1', 'fullscreen=no, titlebar=no, scrollbars=auto');
<!-- 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*

 

by: XombieRxPosted on 2005-02-25 at 22:55:44ID: 13409278

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.PrivilegeManager.enablePrivilege("UniversalBrowserWrite") //request the permission from the user
//alter the state of the window here
netscape.security.PrivilegeManager.revertPrivilege("UniversalBrowserWrite") //we no longer need permission so let go of it...

I am unable to make your script work for your arguments under NN5 and i believe that this is the issue.

 

by: StuperfiedPosted on 2005-02-26 at 00:50:17ID: 13409491

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.

 

by: superslamwichPosted on 2005-10-25 at 11:20:49ID: 15156748

***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}

 

by: devariojPosted on 2009-04-10 at 15:35:34ID: 24119938

Good stuff

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...