Click to See Complete Forum and Search --> : Open browser window error
ragawu
02-25-2003, 06:43 PM
Hi.
I'm having a problem with some javascript which queries the user's browser to find out resolution and then open's a new browser window with no toolbars whatsoever which fills the page.
I have heard that for a minority of users the new browser window contains all the normal toolbars even though I specify them not to be there. What is even stranger is that a user with identical version of interent explorer and java turned on is recieving this error.
Here is the script:
<script language="JavaScript">
<!--
function redirectPage() {
if ((screen.width == 640) && (screen.height == 480))
window.location.href= "640.htm";
else if ((screen.width == 800) && (screen.height == 600)) {
window.open("home.htm","main","width=790,height=550,left=0,top=0");
window.close();
}
else window.open("home.htm","main","width=1015,height=710,left=0,top=0");
window.close();
}
//-->
</script>
"640.htm" is a page telling the user to increase resolution, "home.htm" is the home page with an auto stretch table to fill out the 1024x800 screen. "window.close" refers to the window which launches the new browser window. You can see this script in action at http://www.lapsuslinguae.com when you click on the logo a small window opens containing this script on an onload() event which then opens the main home page.
I would appreciate any help you can offer me - why do the results of this script vary even with identical version of explorer? What is the correct way of signalling the browser to hide all toolbars and scrollbars?
thanks
alasdair
AdamBrill
02-25-2003, 07:59 PM
It is possible that the users that it doesn't work for has their security settings set differently. If they were using the same version of Internet Explorer and with the same settings, then it would work for them, too. ;)
russ_man7
02-25-2003, 08:30 PM
Hope this helps. i'm not totally sure it'll work in NS
if ((screen.width == 640) && (screen.height == 480))
window.location.href= "640.htm";
else
{
var the_window = window.open("the_place.html","window_name","menubar=no,toolbar=no,location=no,status=no,scrollbars=no,directories=no,resizable=no,width="+screen.width+",height="+screen.height);
}
*Bangs head up against the wall*
Yah yah yah yah... I knew that....... :p
ragawu
02-25-2003, 09:11 PM
russman, because I'm crap at javascript, do I have to set up the variable earlier on in the script? or will just this script work?
Originally posted by russ_man7
Hope this helps. i'm not totally sure it'll work in NS
if ((screen.width == 640) && (screen.height == 480))
window.location.href= "640.htm";
else
{
var the_window = window.open("the_place.html","window_name","menubar=no,toolbar=no,location=no,status=no,scrollbars=no,directories=no,resizable=no,width="+screen.width+",height="+screen.height);
}
russ_man7
02-25-2003, 09:30 PM
you're right, i forgot about the whole global/local variable thing. here's the whole thing:
</style>
<script language="JavaScript">
<!--
var the_window;
function redirectPage() {
if ((screen.width == 640) && (screen.height == 480))
window.location.href= "640.htm";
else
{
the_window = window.open("home.htm","main","menubar=no,toolbar=no,location=no,status=no,scrollbars=no,directories=no,resizable=no,width="+screen.width+",height="+screen.height);
}
window.close();
}
//-->
</script>
unless you're really attached to 640.htm, and unless it does more than just tell the user to up their resolution, you probably don't need the whole if else part -- it would just be the window.open and window.close lines. the window.open() fits the new window to whatever size screen. hope that simplifies some things.
good luck
ragawu
02-25-2003, 09:51 PM
now the script fails to work :confused: thansk for your quick response though lol
ragawu
02-25-2003, 09:53 PM
Shoudl I use +screen.availHeight+ instead so that the window doesn't obscure the windows taskbar?
russ_man7
02-25-2003, 10:00 PM
sure, availHeight sounds like a good idea. sorry, most the time i don't think everything through completely, and my working JS vocabulary is borderline pathetic. it makes sense the window would cover the whole screen if you told it to do so. what else is broken now? maybe if you put all of the script up.
Quote from russ_man7
sorry, most the time i don't think everything through completely,
You're not the only one...
russ_man7
02-25-2003, 10:11 PM
that's a relief. to hear some of the people around here, you'd think a syntax error was a mortal sin.
ragawu
02-25-2003, 10:28 PM
Well, basically if any of the scrollbar=no etc were there the script would fail, once I took all of that out the script works, here is how it is at present. but pretty much back to what I had before - no specific instruction to hide all unwanted window elements.
<script language="JavaScript">
<!--
var the_window;
function redirectPage() {
if ((screen.width == 640) && (screen.height == 480))
window.location.href= "640.htm";
else
{
the_window = window.open("home.htm","main","outerWidth="+screen.availwidth+",outerHeight="+screen.availheight);
}
window.close();
}
//-->
</script>
</head>
At the moment strangely enough the page fills out to the correct height - ie stoppign at the taskbar but the width is a few pixels short!! Try it out http://www.lapsuslinguae.com
Something else to consider is that I had intentionally entered specific pixels so that if someone was lookgin at this page on a higher resolution than 1024x800 then the website wouldn't take up all of there screen with more black than content.
I suppose that is something I should muse over. The whole reason behind this is that I want to creae an experience which is astheticaly pleasing as posible, hence no crappy windows tool bars etc.
At the moment I'm struggling to understand why a same version browser will not recognize the basic window.open command and show the elements I don't want..
It's a mystery indeed - does the size of the monitor have any relevance here - I don't think it should, I know for a fact that one person who is recieving errors is using 800x600 on a possible 17inch monitor. This has been tested fine on 800x600 on 14" and 15" and 1024x800 on 15".
by the way I really appreciate your help russman.
thanks