473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with window.open()

Hi guys

The following code works just fine in Netscape on MacOS and Windows. But in
Explorer on MacOS and Windows it throws a type mismatch error at the point
marked with the comment ³// bug out at this point². (The functions that are
called, but not listed here work fine in both Netscape and Explorer in this
and other contexts, so I can confidently discount them as the source of any
error.)

I have also tried just a plain and simple ³window.open()² command with
appropriate parameters, but to no avail. Explorer just does not seem to like
the command. But that is just plain stupid... Microsoft canıt possibly be
wrong, it must be me that is screwing up.

Any help will be most appreciated.

All the best

Ian
var bulletinSignupWindow

function displayBulletinSignup () {
var theURL = "bulletinsignup.htm";
var winName = "Bulletin Signup";
var features = "scrollbars=yes,";
features += "location=no,";
features += "toolbar=no,";
features += "menuBar=no,";
features += "directories=no,";
features += "status=no,";
features += "resizable=no,";
features += "width=500,";
features += "height=500,";
features += "left=30,";
features += "top=30";

bulletinSignupWindow =
openDisplayWindow(bulletinSignupWindow,theURL,winN ame,features);
}

function openDisplayWindow (windowRef,contentURL,windowName,features) {
var whichBrowser = checkBrowser();
var nullWindow;

switch (whichBrowser) {
case "Netscape":
nullWindow = undefined;
break;
case "Explorer":
nullWindow = null;
break;
default:
nullWindow = undefined;
break;
}

if (windowRef == nullWindow) {
windowRef = window.open(contentURL,windowName,features);

if (windowRef != nullWindow) {
windowRef.focus();
}
else {
alert("The " + quoteString(windowName,SQUOTE) + " window cannot be
opened. You might be low on memory.");
}
} ³// bug out at this point²
else {
windowRef.focus();
}

return windowRef;
}
Jul 23 '05 #1
4 2108
DU
Ian Sedwell wrote:
Hi guys

The following code works just fine in Netscape on MacOS and Windows. But in
Explorer on MacOS and Windows it throws a type mismatch error at the point
marked with the comment ³// bug out at this point². (The functions that are
called, but not listed here work fine in both Netscape and Explorer in this
and other contexts, so I can confidently discount them as the source of any
error.)

I have also tried just a plain and simple ³window.open()² command with
appropriate parameters, but to no avail. Explorer just does not seem to like
the command. But that is just plain stupid... Microsoft canıt possibly be
wrong, it must be me that is screwing up.

Any help will be most appreciated.

All the best

Ian
var bulletinSignupWindow
var bulletinSignupWindow = null;

function displayBulletinSignup () {
var theURL = "bulletinsignup.htm";
var winName = "Bulletin Signup";
winName must be a one word string without any blank spaces. This is a
well known issue with MSIE 5+.
var features = "scrollbars=yes,";
features += "location=no,";
features += "toolbar=no,";
features += "menuBar=no,";

features += "directories=no,";
features += "status=no,";
It's pointless, useless and very anti-user to try to remove the status
bar. MSIE 6 SP2, NS 6.2+, Opera 7.x and many other browsers allow the
users, give the users absolute veto power to force presence of status
bar. Why do you want your users to not be able to see http connections,
download, transfer, messages, notifications. Why are you trying to
remove the chrome bar by which I can see if the security padlock icon
(SSL) is locked or opened?
features += "resizable=no,";
So you want to prevent your users from resizing their own browser
window? How user-friendly of you!
features += "width=500,";
features += "height=500,";
If your user's screen is 640x480, then your window position and
dimensions will be corrected by modern browsers. Now, your anti-user
window features will then make the window you created unusable. Even
with a 800x600, your requested height value might be too strict, too
short in a minority of cases.
features += "left=30,";
features += "top=30";

Why do you slow down the whole process of creating that string with 12
string appending.
bulletinSignupWindow =
openDisplayWindow(bulletinSignupWindow,theURL,winN ame,features);

You can replace everything above and everything under (the whole
openDisplayWindow) with this:

if(bulletinSignupWindow == null || bulletinSignupWindow.closed)
{
bulletinSignupWindow = openDisplayWindow("bulletinsignup.htm",
"BulletinSignup", "scrollbars,status,resizable");
}
else
{
bulletinSignupWindow.focus();
};
Often, not defining position and dimensions is better than defining
these values. The reasoning is that the os stores these values as
persistent data so that the next non-maximized window being opened
without strict values will use these stored values.
There is another policy also: make position and dimensions values
entirely proportional, scaled to the user's application workarea values
(it's a bit more complicated but it works).
}

function openDisplayWindow (windowRef,contentURL,windowName,features) {
var whichBrowser = checkBrowser();
var nullWindow;

switch (whichBrowser) {
case "Netscape":
nullWindow = undefined;
break;
case "Explorer":
nullWindow = null;
break;
default:
nullWindow = undefined;
break;
}

if (windowRef == nullWindow) {
windowRef = window.open(contentURL,windowName,features);

if (windowRef != nullWindow) {
windowRef.focus();
Not optimized here too. You only need 1 if..else; not 2 if(){..} .
}
else {
alert("The " + quoteString(windowName,SQUOTE) + " window cannot be
opened. You might be low on memory.");
Not low on memory. One string without blank spaces.
}
} ³// bug out at this point²
else {
windowRef.focus();
}

return windowRef;

This whole openDisplayWindow function can be replaced by much more
efficient code without jeopardizing cross-browser interoperability.

}


DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Netscape 7.2 :)
Jul 23 '05 #2
Hi DU

Many thanks for your response. I appreciate the technical assistance.

As for the actual use of windows in web sites, I have a great deal of
sympathy with all that you say. I am not actually in favour of using
multiple windows in a web site. Hitherto, I have always used frames or <div>
layers to do what the client wants done here. But it is the client's choice.
I have made my case in favour of what I think both you and I would agree is
the more "friendly" way of doing things, but...

As to the size of the window. That's a red-herring. The dimensions in my
code are quite arbitrary. For the convenience of people of reading the code
I had posted as an exemplar, I had removed the code that tested the user's
screen size, set the window size accordingly and inserted scroll bars if
required. In fact this window (one of four the client wants) will only ever
contain a small table of results and there would be no point in making it
scrollable or resizable, unless the screen was too small. For the others,
that is not the case, they will contain considerable chunks of information
and so must scroll, though for cosmetic reasons I will still not allow them
to be resized. And none of them will have address, tool, menu or status
bars, either - on the client's instruction - so you can continue with your
admonishments!

Thanks again

Ian

On 2004/09/04 17:57, in article 2p************@uni-berlin.de, "DU"
<dr*******@hotNOSPAMmail.com> wrote:
Ian Sedwell wrote:
Hi guys

The following code works just fine in Netscape on MacOS and Windows. But in
Explorer on MacOS and Windows it throws a type mismatch error at the point
marked with the comment ³// bug out at this point². (The functions that are
called, but not listed here work fine in both Netscape and Explorer in this
and other contexts, so I can confidently discount them as the source of any
error.)

I have also tried just a plain and simple ³window.open()² command with
appropriate parameters, but to no avail. Explorer just does not seem to like
the command. But that is just plain stupid... Microsoft canıt possibly be
wrong, it must be me that is screwing up.

Any help will be most appreciated.

All the best

Ian
var bulletinSignupWindow


var bulletinSignupWindow = null;

function displayBulletinSignup () {
var theURL = "bulletinsignup.htm";
var winName = "Bulletin Signup";


winName must be a one word string without any blank spaces. This is a
well known issue with MSIE 5+.
var features = "scrollbars=yes,";
features += "location=no,";
features += "toolbar=no,";
features += "menuBar=no,";

features += "directories=no,";
features += "status=no,";


It's pointless, useless and very anti-user to try to remove the status
bar. MSIE 6 SP2, NS 6.2+, Opera 7.x and many other browsers allow the
users, give the users absolute veto power to force presence of status
bar. Why do you want your users to not be able to see http connections,
download, transfer, messages, notifications. Why are you trying to
remove the chrome bar by which I can see if the security padlock icon
(SSL) is locked or opened?
features += "resizable=no,";


So you want to prevent your users from resizing their own browser
window? How user-friendly of you!
features += "width=500,";
features += "height=500,";


If your user's screen is 640x480, then your window position and
dimensions will be corrected by modern browsers. Now, your anti-user
window features will then make the window you created unusable. Even
with a 800x600, your requested height value might be too strict, too
short in a minority of cases.
features += "left=30,";
features += "top=30";


Why do you slow down the whole process of creating that string with 12
string appending.
bulletinSignupWindow =
openDisplayWindow(bulletinSignupWindow,theURL,winN ame,features);

You can replace everything above and everything under (the whole
openDisplayWindow) with this:

if(bulletinSignupWindow == null || bulletinSignupWindow.closed)
{
bulletinSignupWindow = openDisplayWindow("bulletinsignup.htm",
"BulletinSignup", "scrollbars,status,resizable");
}
else
{
bulletinSignupWindow.focus();
};
Often, not defining position and dimensions is better than defining
these values. The reasoning is that the os stores these values as
persistent data so that the next non-maximized window being opened
without strict values will use these stored values.
There is another policy also: make position and dimensions values
entirely proportional, scaled to the user's application workarea values
(it's a bit more complicated but it works).
}

function openDisplayWindow (windowRef,contentURL,windowName,features) {
var whichBrowser = checkBrowser();
var nullWindow;

switch (whichBrowser) {
case "Netscape":
nullWindow = undefined;
break;
case "Explorer":
nullWindow = null;
break;
default:
nullWindow = undefined;
break;
}

if (windowRef == nullWindow) {
windowRef = window.open(contentURL,windowName,features);

if (windowRef != nullWindow) {
windowRef.focus();


Not optimized here too. You only need 1 if..else; not 2 if(){..} .
}
else {
alert("The " + quoteString(windowName,SQUOTE) + " window cannot be
opened. You might be low on memory.");


Not low on memory. One string without blank spaces.
}
} ³// bug out at this point²
else {
windowRef.focus();
}

return windowRef;

This whole openDisplayWindow function can be replaced by much more
efficient code without jeopardizing cross-browser interoperability.

}


DU


Jul 23 '05 #3
On Sun, 5 Sep 2004 16:34:16 +0000 (UTC), Ian Sedwell
<ia*********@btclick.com> wrote:
I will still not allow them
to be resized. And none of them will have address, tool, menu or status
bars, either - on the client's instruction - so you can continue with your
admonishments!


So what are you going to do about the fact that much of what you've
just described is impossible in IE6 SV1 (currently only in XP SP2 but
will be in other IE6's soon)

Jim.
Jul 23 '05 #4
Hi Jim

That is my understanding too. Thank you for confirming it. I haven't looked
at the issue in detail myself, but I have seen some technical papers. Which
is one of the reasons I have been arguing with my client against the use of
these windows in any case. The other is I do not like multi-window web
sites. It seems to that it is poor practice for a good number of reasons
that need not be rehearsed here.

As to what I am going to do... Well, I am naturally exercising due diligence
and I have an entirely frame-based version that I will produce as if by
magic from a hat as soon as the client complains that people can't use his
web site :-)

All the best

Ian

On 2004/09/05 17:44, in article 41****************@news.individual.net, "Jim
Ley" <ji*@jibbering.com> wrote:
On Sun, 5 Sep 2004 16:34:16 +0000 (UTC), Ian Sedwell
<ia*********@btclick.com> wrote:
I will still not allow them
to be resized. And none of them will have address, tool, menu or status
bars, either - on the client's instruction - so you can continue with your
admonishments!


So what are you going to do about the fact that much of what you've
just described is impossible in IE6 SV1 (currently only in XP SP2 but
will be in other IE6's soon)

Jim.


Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Anna Quick | last post by:
I am quite new to javascript, and don't seem to find the problem with stupid internet explorer. The script works fine in safari and mozilla. I searched the groups, but evidently put in the wrong...
5
by: Mike | last post by:
In my previous post, I wrote: > ... > GOAL: (very simple) Provide a hyperlink which, when clicked, > calls a javascript function which opens a new URL. > ... > PROBLEM: The following code...
10
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a...
2
by: Samir Pandey | last post by:
Hello, I am using the following javascript code to open a new window. Somehow, IE always opens a new window. It doesn't open target url in the window name given. All i want is, if there is a...
5
by: Richard Trahan | last post by:
I have an inscrutable problem with window.open. Consider the following code: var graphwin = window.open("","graphWin","height=400,width=400,resizable=yes"); It works perfectly in one place in...
4
by: VR | last post by:
First, greetings to everyone :) I'm doing a university seminar & I've encountered a problem. I have a gallery with thumbnails linked on pictures. What I want is popup to be opened with...
18
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to...
0
by: Aryan | last post by:
Hi, I am doing "Export to Excel" functionality, but while doing this I am getting error. Like I have two types of Report, each type has many sub reports inside. So I am opening new window for Each...
0
by: Aryan | last post by:
Hi, I am doing "Export to Excel" functionality, but while doing this I am getting error. Like I have two types of Report, each type has many sub reports inside. So I am opening new window for Each...
0
by: Aryan | last post by:
Hi, I am doing "Export to Excel" functionality, but while doing this I am getting error. Like I have two types of Report, each type has many sub reports inside. So I am opening new window for Each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.