Disable Menubar, Toolbar, Status etc. in Java Script

RadhaKrishnaKiJaya
RadhaKrishnaKiJaya used Ask the Experts™
on
Hi Experts,
I am coding a .aspx page.  When the window opens, the size should be small and at the same time, should be able to disable Menubar, Toolbar, Status etc. I have the code below, which opens a smaller window, but Menubar, Toolbar etc. still remans enabled.  Please help.  Thank you in advance.

function SmallWindow() {window.resizeTo(850,580),menubar=false,toolbar=false,status=no,resizable=true}
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes, width='768px',height='1155px',left=50, top=25";

window.open("","",disp_setting);

Commented:
Here is the complete code
function SmallWindow() {
var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes, width='850px',height='580px',left=50, top=25";

window.open("","",disp_setting);
}

Author

Commented:
Hi Prasad,
I tried your code as it is.  It simply opens a regular window.  I am executing the function as  below.  Am I making any mistake?  Thank you very much for your help.

<body bgcolor="#ffffff" leftmargin="0" topmargin="0" rightmargin="0" onload="SmallWindow();">

Commented:
You need to supply url to window.open() function along with other parameters

Commented:
function SmallWindow() {
var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes, width='850px',height='580px',left=50, top=25";

window.open("http://www.microsoft.com", "mywindow",disp_setting);
}

Replace microsoft.com with your page url

Author

Commented:
It should open the same page, name is xyz.aspx.  So, what should be my URL?

Commented:
try
"xyz.aspx"
Michel PlungjanIT Expert
Top Expert 2009

Commented:
VERY simple answer: NOT possible on the web

If you save the file with extension .HTA instead of HTML, you can open it from the harddisc - just forget it otherwise
NO new browsers will allow you to change the existing chrome

Author

Commented:
Prasad, I already tried this as below, which doesn't work.

function SmallWindow() {
var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes, width='850px',height='580px',left=50, top=25";var disp_setting = "width='850px', height='580px';
      window.open("xyz.aspx",disp_setting);
}

Commented:
its not finding a relative path.

You need to create full path to that xyz.aspx
instead of just call the page

Author

Commented:
It is running in local host.  Here is the code.  

window.open("http://localhost/ProjectName/xyz.aspx",disp_setting);

You can let me knot the path assuming it is running on local host.
IT Expert
Top Expert 2009
Commented:
Did you read my post?
What you want is not possible. Period.
You will need to open a new window or use something like jquery dialog
Michel PlungjanIT Expert
Top Expert 2009

Commented:
To open a window the syntax is
window.open(url,windowname,parameters)
The parameters must not have spaces, do not need to have =yes or =1 and you can leave the =no out since if you have just ONE parm, all the others are off by default. Also you cannot quote or have px (which is default) inside the parameters

so you want

function SmallWindow() {
  var disp_setting = "scrollbars,resizable,width=850,height=580,left=50,top=25";
  var windHandle = window.open("xyz.aspx","_blank",disp_setting);
}

Open in new window

Author

Commented:
Hi mplungjan,
Thank you for your reply.  I could not make your code work.  Do I need anything else apart from the above code?  The code below works just fine, but I cannot add any other parameter like menubar, toolbar etc.  Could you please take a look and add these two parameters if possible?  Many thanks for your help.

function SmallWindow() {window.resizeTo(850,580)}
Michel PlungjanIT Expert
Top Expert 2009

Commented:
As I said, you CANNOT add these parameters to the EXISTING window
You can ONLY resize and people do not like that since for example IE will remember that size.

The code I gave will open a NEW window

So if you want to show the current page in a new window, you can do something like




<html>
<head>
<script>
function SmallWindow(url) {
  var disp_setting = "scrollbars,resizable,width=850,height=580,left=50,top=25";
  var windHandle = window.open(url,"_blank",disp_setting);
}
if (!location.search || location.search.indexOf('pop')==-1) {
  SmallWindow(location.href+'?pop'); // change to &pop if you already have a ? in the url
  location.replace('thanks.html'); // create a thanks.html which will take the place of this 
}
</script>

Open in new window

Author

Commented:
Hi mplungjan, This is very simple question.  I am working on VS2003 env.  When I run the current .aspx page, it should open a small window with no menubar.  Normally it open the full screen.  Here I don't need to click any button, or no other event I am generating. I hope I am this clarifies my question better now.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
Is the idea that someone when you have deployed your project will open the asp page in a browser and then the browser will lose its menu bar?
If that is so, the answer is: impossible

If you are deploying some web application that runs on a desktop from VS2003, then I cannot tell you what to do since I am not at all familiar with Visual Studio.

Author

Commented:
Thnak you mplungjan for your reply.  Understood, but I used your code, it does open the window for the defined properties, but keeps on running (with a contineous clicking noise) as if running in a loop, till you force stop the program.  Thank you for help.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
The code I gave may loop if the location.search has not been set correctly. I did not test it so I will take a look later
Michel PlungjanIT Expert
Top Expert 2009

Commented:

Author

Commented:
mplungjan, Thank you for helping me.  I tried your link.  It works, but not as I need.  It opens two windows, one in fullscreen and the 2nd one with the properties you supplied.  My requirement is totally different.  The 1st srceen should have all the properties you have supplied to your 2nd screen.  

I have only one screen.  When the screen opens, it should meet all the requirements of your 2nd screen.  Still I don't know if you understand my requirement.  Please ask me questions before you spend any further time.  Thank you very much again.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
I completely understand your requirements. I have SEVERAL times explained that your requirements are not fulfillable in todays browsers. So I gave you the only workaround possible. I repeat: the answer to your question is: NOT POSSIBLE. You will need to build your own browser or use one of the solutions I have given

Author

Commented:
Vee_Mod, After working for saveral hours, some times few days, if the any of the resolution doesn't work, I need to find a different way.  At that point of time, I need to close the current question.  Please let me know what else I could do?  Thanks.

Author

Commented:
alias99, Are you forcing me to accept an answer even if it is not a resoulation for me?
Michel PlungjanIT Expert
Top Expert 2009

Commented:
I do not understand your position.

You need to do something and the experts at this site tell you it is not possible. that is an answer that is worth something since you can take it to whoever asked you to do this and tell them it is not possible and can let you get on with something else.

I even gave you working alternatives to what is impossible and you are still not satisfied until we SOLVE your unsolvable problem.

So yes, we expect you to give a top grade and a thank you for clearing up the issue. Do not shoot the messenger.

Thanks

Author

Commented:
First of all clarify, who am I taking with.  I am talking to mplungjan: or alias99:.  I am confused.  What do you mean by Do not shoot the messanger?  Also, stop talking like boss.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
"Don't shoot the messenger" or punish the bearer of bad news. I commented since you did not get a clarification yet from the mod. And we are all volunteers. And I am  zone advisor and top js expert at EE for more than a decade. Just trying to advise and help you without you thinking we are trying to cheat you or whatever.

Author

Commented:
I am going to close this quesiton as this doesn't have a solution as I want and at the same time I agreed to the experts alternatives.  Thank you all for your efforts and unconditional help.  Please keep doing so...
Michel PlungjanIT Expert
Top Expert 2009

Commented:
You are very welcome...


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial