aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Not Able to detect Javascript window open Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Not Able to detect Javascript window open" Watch "Not Able to detect Javascript window open" New topic
Author

Not Able to detect Javascript window open

Andy Smith
Ranch Hand

Joined: Sep 28, 2003
Posts: 239
I have a requirement where no more then one javascript window should be open at the same time.

If a window is already open then we need to show a alert message.

Its working fine...

But in live envrioment, users are reporting this problem

They are getting the alert message even though no window is open.

This problem is occurring once in a blue moon.

Any idea?


Share Knowledge to gain it.
SCJP 2, SCWCD 2, SCDJWS, IBM 141 (In Progress), IBM 486 (Next)
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
And this magic code you are using is?

I have no clue what you are using to detect if a window is open.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

I think the problem is on line 42.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Originally posted by Andy Smith:
But in live envrioment, users are reporting this problem

They are getting the alert message even though no window is open.

This problem is occurring once in a blue moon.

Any idea?


Get new users.
Andy Smith
Ranch Hand

Joined: Sep 28, 2003
Posts: 239
Yes there may be many ways to achieve this.

But for me I need to locate the problem in the existing code.
Here is it. Your views required.
********************
OK this is the method getting used...

function showWindow(windowName,url){
var openwindow = false;
var warning = "U already have a window Open";
if (isWindowPresent(windowName))
{
if (confirm(warning))
{
openwindow = true;
} else {
mymyTestWindow.focus();
}
} else {
openwindow = true;
}

if (openwindow) {
var myRequestWin;
if (!(myRequestWin == null || myRequestWin.closed)) {
myRequestWin.close();
}
myRequestWin = null;
myRequestWin = window.open('',windowName, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=800,height=615,top=30,left=100");
myRequestWin.focus();
myRequestWin.location.href = url;
} else {
return false;
}
}


function isWindowPresent(winName) {
strFeatures = "width=1,height=1,left=9999,top=9999";
myTestWindow = window.open('', windowName, strFeatures);
if (myTestWindow.top.screenLeft >= 9999) {
myTestWindow.close();
return false;
}
else {
return true;
}
}
****************************
Andy Smith
Ranch Hand

Joined: Sep 28, 2003
Posts: 239
Just to add to earlier note, I have not been able to reporoduce the problem..
Its just the few times users have complained
Andy Smith
Ranch Hand

Joined: Sep 28, 2003
Posts: 239
Any help would be really appreciated....
[ April 16, 2006: Message edited by: Andy Smith ]
Andy Smith
Ranch Hand

Joined: Sep 28, 2003
Posts: 239
Any UPdates, It has become really really urgent now....
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You are breaking rules of not having a page in the url and opening a window outside of the avaiable space on the page. Also have you looked into pop up blockers and such and see what they do to your code?

Set the url when you open. Why bother opening it off the screen if you are going to open it again? Use a modal window if you are worried about multiple windows.

Eric
Andy Smith
Ranch Hand

Joined: Sep 28, 2003
Posts: 239
1. I am providing the URL with this "myRequestWin.location.href = url;"

2. I am opening the trying to open the window outside the boundaries, just to check whether a window aleady exists, this window is there just for a fraction of seconds before the actual window is opened.

Yes, we have several other ways to acheive this, but I can't change the live code easily, first I need to reproduce the issue, in which I have failed till now. Niether I am able to find any problem while self review.

Any help/Comments would be highly appreciated.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Why do you have to open a window to detect if ones exists. Sounds redundant to me? You mean open one to check to see if it can be opened.

What I mean by setting the url is the FIRST parameter in the window.open statement. Certain browsers have security issues when you do not specify a page. So why in the world would you set the url later when you can do it while opening the window.

Eric
Andy Smith
Ranch Hand

Joined: Sep 28, 2003
Posts: 239
Eric I may not be able to answer ur questions... as I am not the one who has coded it.
I am in production support just maintaining this code...

This code is working fine... its just that its giving problem once in a very long time... but since we have faced this problem 2-3 times in past 6 months.. we are trying to solve...

Hope u can understand I can not touch the code, before I am able to find the problem / or atleast able to reproduce the mentioned problem...


Where as the blank URL etc... is working...
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I would hire the people that coded it. Actually, by the way it is written it is old.

I was going to post this code


But since you are only supporting it, it is too much of a drastic change. LOL

When an error occurs, do you get the browser and if they have a pop up blocker installed? That could be as simple as telling them to add you to their safe list.

Other problems is that strange testing. Have no clue why someone would do that....

Eric
Andy Smith
Ranch Hand

Joined: Sep 28, 2003
Posts: 239
No they dont have any pop up blocker...

They are using IE browser > 5.5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not Able to detect Javascript window open
 
Similar Threads
JavaScript window.closed on PDF/DOC Window
Is Child Window Open?
Closing multiple pop-up windows?
Error: Permission Denied
Handle window close event