problem with open popup on IE6

L

ldan

Hi everybody,

I would not consider myself an expert in javascript - but so far
whatever I know, helped me reaching my goals. Recently I started to
experience a lot of javascript errors related to opening up a popup
window in an application I wrote.

The error messages are quite diverse: "Object doesn't support this
property or method" or "Unspecified error." or "The callee (server [not
server application]) is not available and disappeared; all connections
are invalid. The call did not execute.". They all occur in same
function "openPopup".

All my clients use Windows XP and IE6 and they have popup blockers
turned off; also there is no other software installed (like search
toolbars, etc) that I know of. Some of them told me that after
restarting the computer the problem goes away for a while. It's not
consistent and it's not experienced constantly even on the same
computer.

The function is trying to re-use same popup window every time. I will
post below the code:

//*** CODE Begin ***

var refPopupWindow = null;

// ........

function openPopup(aUrl) {
if (refPopupWindow) refPopupWindow.close();
refPopupWindow =
window.open(aUrl,'refPopupWindow','left=0,top=0,toolbar=0,menubar=0,dependant=1,location=0,scrollbars=1,resizable=1,width=500,height=300');
if ((refPopupWindow) && (typeof(refPopupWindow) == 'object') &&
(refPopupWindow.focus))
refPopupWindow.focus();
else
alert('Unable to open popup window');
}

//*** CODE End ***

The errors are usually thrown for lines that either are closing or
trying to focus on window. I don't know if this is the best way of
opening a re-usable popup window or if this is the "recommended" way of
coding it.

Any suggestions, critics or any other ideas would be appreciated - It's
been quite a while and I cannot figure this one out.

Thanks,
Dan
 
V

VK

ldan said:
All my clients use Windows XP and IE6 and they have popup blockers
turned off; also there is no other software installed (like search
toolbars, etc) that I know of. Some of them told me that after
restarting the computer the problem goes away for a while. It's not
consistent and it's not experienced constantly even on the same
computer.

Your workgroup (or whatever it is) is switching on XP SP2 or greater
where the build-in pop-up blocker is ON by default.
<http://support.microsoft.com/default.aspx?scid=kb;en-us;888021>
Check the browser security settings on each newly updated computer.
 
L

ldan

Thanks for the reply.
This is weird. They are running XP SP2 and we walked them through
disabling the IE builtin popup blocker. Also the security settings were
reset to their default settings on each computer. They have also
confirmed that the 'popup blocker' option was turned off.

Second, maybe it's not the most important but I believe it's worth to
be mentioned, the code that opens up the popup windows has been
rewritten to avoid "automatic" popup opening (i.e. onload event) just
to bypass blockers. All popups are displayed as a direct result of a
user clicking a link.
 
V

VK

ldan said:
Thanks for the reply.
This is weird. They are running XP SP2 and we walked them through
disabling the IE builtin popup blocker.

Popup blockers are a newly new hot stuff in the Net, so everyone is
trying to include it in their product. It's getting like a kind of an
anti-popup virus: you can get it from the least expected installation
:)
Check all your antivirus software (Norton? Panda? MacAffee? they are
all coming now with anti-popup), spyware software and so on.
 
G

Gérard Talbot

ldan a écrit :
Hi everybody,

I would not consider myself an expert in javascript - but so far
whatever I know, helped me reaching my goals. Recently I started to
experience a lot of javascript errors related to opening up a popup
window in an application I wrote.

The error messages are quite diverse: "Object doesn't support this
property or method" or "Unspecified error." or "The callee (server [not
server application]) is not available and disappeared; all connections
are invalid. The call did not execute.". They all occur in same
function "openPopup".

All my clients use Windows XP and IE6 and they have popup blockers
turned off; also there is no other software installed (like search
toolbars, etc) that I know of. Some of them told me that after
restarting the computer the problem goes away for a while. It's not
consistent and it's not experienced constantly even on the same
computer.

The function is trying to re-use same popup window every time. I will
post below the code:

//*** CODE Begin ***

var refPopupWindow = null;

// ........

function openPopup(aUrl) {
if (refPopupWindow) refPopupWindow.close();

That is nonsense. If the reference exist, why close the window? It may
be closed already by the user anyway too. You're calling a particular
function (to close the window) without first verifying if it is useful
to do so.
If the same window with the same URL has to be reopened, then why not
just bring it on top? Why close it?

Also, some browsers will not honor your request. Mozilla users can
disable [frivolous] calls to window close. If an user does not want a
script to automatically open a window, why would he want a script to be
able to close automatically a window as well? Users can close a window
or decide to close a window without any needed help.
refPopupWindow =
window.open(aUrl,'refPopupWindow','left=0,top=0,toolbar=0,menubar=0,dependant=1,location=0,scrollbars=1,resizable=1,width=500,height=300');

First, you have a very bad coding technique here. The window object
reference should not be using the same identifier used to define the
window name. It's not wise (for debugging, for reviewing by others,
etc.) to use the same name. It may create side effects too.

dependant is wrongly written and, on top of this, such window feature is
not supported by MSIE 6.
If you define the windowFeatures string list, then there is no need to
define the ones which are turn off.

So:

refPopupWindow = window.open(aUrl, "PopupName",
"left=0,top=0,scrollbars=yes,resizable=yes,width=500,height=300");

if ((refPopupWindow) && (typeof(refPopupWindow) == 'object') &&
(refPopupWindow.focus))
refPopupWindow.focus();

Again, this is pure non-sense. You first close the window. Then you
create a window and now you query some properties and method just to
bring it on top. What you do here is that you over-code and your code is
counter-productive.
else
alert('Unable to open popup window');
}

//*** CODE End ***

The errors are usually thrown for lines that either are closing or
trying to focus on window. I don't know if this is the best way of
opening a re-usable popup window or if this is the "recommended" way of
coding it.

Just over the examples in this webpage carefully and follow the tips:

Gecko DOM window.open reference:
http://developer.mozilla.org/en/docs/DOM:window.open

in particular the Best practices section/example

Gérard
 
L

ldan

Gerard,

First, thank you for your reply.

Regarding window.close:
I know it looks strange that I'm trying to close a window that exists
but one of the things that my client wanted is to have the popup window
"cleared" of previous content if the window already existed and then
have the new content populate the window. I tried
ref.document.innerHTML = '' but it did not work, so I used this
"nonsense" approach. I still believe it's of no value - but it was not
my decision. In other words, if it really bugs you, please ignore it.

The only browser that client is using right now is IE6 (and it's kind
of a closed user group) - so other browser compatibility is out of the
question for now. "dependant" flag - you're right it does not work for
IE but it won't affect it either.

I will look at the best practices link and I will make the corrections
you suggested.
 
L

ldan

They are using Norton Antivirus. There should be no other software
installed. Unfortunately I have no access (physical or remote
connection) to those sites in order to check what's installed on those
workstations.
 
V

VK

The callee (server [not server application]) is not available and disappeared;
all connections are invalid. The call did not execute.".
They are using Norton Antivirus.

These are two key details:
the first points to the 3rd party (non-Microsoft) popup blocker
the second tells us what popup blocker it is.

As you cannot recommend deinstall antivirus to your clients, you have
two options:
1) Write a .WHS script and send it to each of your customers to run.
This script has to allow popups from your site or kill Norton popup
blocker totally. The first is definitely better but I don't know if
it's possible with Norton (I'm a Panda guy).
2) Make popupless version of your site loaded by default and open
single popup onload redirecting to popup-enabled version. So if the
initial popup is blocked, user just stay where (s)he is.

I guess that there is no use to detect if myPopup exists or no. As
<http://support.microsoft.com/default.aspx?scid=kb;en-us;888021> shows
it's a IE failure: it cannot detect popup block from a 3rd party. So
after window.open it gets an "imaginary object": window that exists in
the program context but doesn't exists in the reality (in graphics
context). This situation traditionally kills IE.

Just for fun of it you may check the try-catch block in hope that it's
more sensitive:
try {window.open...} catch (e) {noPopup();}
 
R

Randy Webb

VK said the following on 10/24/2005 2:43 PM:
The callee (server [not server application]) is not available and disappeared;
all connections are invalid. The call did not execute.".

They are using Norton Antivirus.


These are two key details:
the first points to the 3rd party (non-Microsoft) popup blocker
the second tells us what popup blocker it is.

As you cannot recommend deinstall antivirus to your clients, you have
two options:
1) Write a .WHS script and send it to each of your customers to run.
This script has to allow popups from your site or kill Norton popup
blocker totally. The first is definitely better but I don't know if
it's possible with Norton (I'm a Panda guy).
2) Make popupless version of your site loaded by default and open
single popup onload redirecting to popup-enabled version. So if the
initial popup is blocked, user just stay where (s)he is.

I guess that there is no use to detect if myPopup exists or no. As
<http://support.microsoft.com/default.aspx?scid=kb;en-us;888021> shows
it's a IE failure: it cannot detect popup block from a 3rd party. So
after window.open it gets an "imaginary object": window that exists in
the program context but doesn't exists in the reality (in graphics
context). This situation traditionally kills IE.

Just for fun of it you may check the try-catch block in hope that it's
more sensitive:
try {window.open...} catch (e) {noPopup();}

That won't work with Norton since it doesn't disable window.open, it
redefines it so that it is still accessible in an if(window.open) or
try(window.open) but it doesn't open a window.

And yes, there is a way to detect a popup window and write to it if it
exists and to write to the current page if the popup is not opened.
 
V

VK

And yes, there is a way to detect a popup window and write to it if it
exists and to write to the current page if the popup is not opened.

Actually *not* in IE. The situation appeared to be much more crucial
then I thought. The code below has ben tested with IE 6 SP1 and my
anti-popup (Pop-Up Stopper from panicware.com, "Agressive pop-up
control mode")

<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
var wndPopup = null;

function test() {
//wndPopup = window.open('about:blank');
try {
wndPopup = window.open('about:blank');
}
catch(e) {
alert(e.message);
}
}
</script>
</head>

<body bgcolor="#FFFFFF" onload="test()">
<a href="javascript:void(alert(wndPopup))">Check popup</a>
</body>
</html>

The commented line
wndPopup = window.open('about:blank');
gives you runtime error and halts the script execution. So you never
get a chance to check if your browser can open popups. The runtime
error has three types (average % from 100 runs):

1. "The callee (server [not server application]) is not available and
disappeared;
all connections are invalid. The call did not execute." - 80%

2. "The RPC server is unavailable" - 15%

3. "Unspecified error" - 5%

On the first attempt on the fresh page the first error always comes
first. 2nd and 3rd errors are appearing sporadically if you tortue the
same page long enough.

Only try-catch block allows you to prevent the script execution abort.

The Microsoft position (as I got it) is: "Do not use 3rd party popup
blockers". With 82% market share and a global epidemie of anti-popups
from everywhere it means that within a year or less pupup usage will be
limited to the intranet area where you can admin the enviroment.

IE's window.showModalDialog method seems not affected by popup blockers
and it doesn't lead to script errors.

As I'm finding this issue high-crucial, I copy this message to the new
post as FAQENTRY.
 
R

Randy Webb

VK said the following on 10/25/2005 4:09 AM:
Actually *not* in IE.

Actually, *yes* in IE.
The situation appeared to be much more crucial then I thought.

Then you didn't think about it much.
The code below has ben tested with IE 6 SP1 and my anti-popup
(Pop-Up Stopper from panicware.com, "Agressive pop-up control mode")

Then you need a better popup blocker.
 
V

VK

Then you need a better popup blocker.

The original issue (see the top) has been reise by Symantec Norton
Antivirus. Should we sign it to the "no-name unsupported software"
category? IMHO it would be too dare to do so.
 
R

Randy Webb

VK said the following on 10/25/2005 6:42 AM:
The original issue (see the top) has been reise by Symantec Norton
Antivirus. Should we sign it to the "no-name unsupported software"
category? IMHO it would be too dare to do so.

See me other reply about this. But if Norton is crashing a browser that
wouldn't crash otherwise, then yes, it is crappy software that needs to
either be fixed or ditched. Its a problem with the blocker, not with the
scripting.
 
G

Gérard Talbot

ldan a écrit :
Gerard,

First, thank you for your reply.

Regarding window.close:
I know it looks strange that I'm trying to close a window that exists
but one of the things that my client wanted is to have the popup window
"cleared" of previous content if the window already existed and then
have the new content populate the window.

You should have stated this clearly from the beginning. Over here, I
cannot see or guess or figure out what exactly are your webpages
requirements. If the existing window must load a new url, then just do
so using the target if the link is in the opener, otherwise, just
customize the function to use a strUrl as a function parameter. Over
here, I don't see the whole picture of how you arrange all this...

I tried
ref.document.innerHTML = '' but it did not work,

Stop trying; start understanding. I gave you an excellent
resource/reference to read, to use, with examples, etc..

so I used this
"nonsense" approach. I still believe it's of no value - but it was not
my decision. In other words, if it really bugs you, please ignore it.

The only browser that client is using right now is IE6 (and it's kind
of a closed user group) - so other browser compatibility is out of the
question for now. "dependant" flag - you're right it does not work for
IE but it won't affect it either.

I will look at the best practices link and I will make the corrections
you suggested.

This is my recommendation.

Gérard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top