champ_010
asked on
<body onload=resize window, position, no toolbars, no scrollbars
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
- 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 ***
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
*** Window close hack removed by mplungjan, EE page editor ***
ASKER
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?
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).
ASKER
the parent window remains open, but has changed to show the same page as the pop up. i would like it not to change...
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
-*- 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
ASKER
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.
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 ,scrollbar s=no,resiz able=no,di rectories= no,locatio n=no,width =" + width + ",height=" + height + ",left=" + left + ",top=" + top);
}
Hope that works for you ;-) !
{Slam}
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 h=='') {
newwin=window.open(documen 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);
self.close()
}
</script>
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>
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 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
Thanks,
I was having a similar problem, and that's helped tremendously
brooza
I was having a similar problem, and that's helped tremendously
brooza
What a great JS!!! This is good stuff, superslamwich...
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}
*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 h=='') {
newwin=window.open(documen 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);
self.parent = self;
self.parent.close()
}
</script>
<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>
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. :-/
"technically considered a hack" ?
Jeezzum...half of everything EVER done by ANY CS person is a hack.
What kind of BS censorship is that?
Jeezzum...half of everything EVER done by ANY CS person is a hack.
What kind of BS censorship is that?
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.
Agreeing with the comments. Well, it looks like the word 'HACK' needs to be redefined. lol.
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!
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!
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?
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 h=='') {
newwin=window.open(documen 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);
self.parent = self;
self.parent.close()
}
}
</script>
<body onload="SetWindow();">
<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();">
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.
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.
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}
{Slam}
BTW, e-mail change for the question, you can now reach me at: sborchard at sps.edu
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 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();
Try using the following adjustment to the code though...
// Cannot perform across all browsers
this.focus();
*** hack removed, mplungjan, ee page editor ***
self.close();
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
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
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.
About the code... I have only tested that code on IE, Mozilla, and Netscape. It only works in IE so far.
Oops... Forgot the customary "you're welcome". Hehehe... You are welcome. :D
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
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!
To make sure it happens, I will go to the customer service area and make the request that way.
Take Care!
Take Care!
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}
{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.
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.
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.
You need to put this in a new question showing your code, the line givng the error, and a thorough description of the error.
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}
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 eManager.e nablePrivi lege("Univ ersalBrows erWrite")
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.Privileg eManager.r evertPrivi lege("Univ ersalBrows erWrite")
resizeTo(width,height); //replace with actual numerical values
}
</script>
hope this helps. please email me with feed back: xombierx at yahoo dot com
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 erCase();
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 h=='') {
window.open(document.locat ion + "?newwin=true",name,"fulls creen=no,t oolbar=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);
// *** hack removed, page editor ***
// self.close()
} else
{
window.opener.close();
}
} else {
netscape.security.Privileg eManager.e nablePrivi lege("Univ ersalBrows erWrite")
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.Privileg eManager.r evertPrivi lege("Univ ersalBrows erWrite")
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}
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 erCase();
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 eManager.e nablePrivi lege("Univ ersalBrows erWrite")
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.Privileg eManager.r evertPrivi lege("Univ ersalBrows erWrite")
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 h=='')
{
window.open(document.locat ion + "?newwin=true",name,"fulls creen=no,t oolbar=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);
// *** 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
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
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}
Thanks for correcting the error.
{Slam}
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 h=='') {
newwin=window.open(documen t.location + "?newwin=true", name, "fullscreen=no,toolbar=no, status=no, menubar=no ,scrollbar s=no,resiz able=yes,d irectories =no,locati on=no,widt h=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
this.focus();
// *** hack removed ***
self.close();
}
}
</SCRIPT>
<BODY onload="SetWindow_DesktopM ode();">
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 h=='') {
newwin=window.open(documen t.location + "?newwin=true", name, "fullscreen=no,toolbar=no, status=no, menubar=no ,scrollbar s=no,resiz able=yes,d irectories =no,locati on=no,widt h=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
this.focus();
// *** hack removed again and again ***
self.close();
}
}
</SCRIPT>
<BODY onload="SetWindow_TabletMo de();">
...anybody willing to steer me in the right direction?
Thanks,
-s_ferguson
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
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}
So instead of
var name = "winname" //Set window name
make it
var name = "winname2" //Set window name
or something else
{Slam}
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
Slam, thanks for the quick response!
Best,
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=[ Value];
Attributes (Mozilla):
menubar, directories,
statusbar, toolbar,
locationbar, personalbar,
scrollbars
Method(Internet Explorer):
scroll="[Value]"
Method(Cross Browser);
parent.resizeTo(width,heig ht);
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*
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 eManager.e nablePrivi lege("Univ ersalBrows erWrite") //request the permission from the user
//alter the state of the window here
netscape.security.Privileg eManager.r evertPrivi lege("Univ ersalBrows erWrite") //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.
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.
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}
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}
Good stuff
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>