• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not Able to detect Javascript window open

 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And this magic code you are using is?

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

Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the problem is on line 42.
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help would be really appreciated....
[ April 16, 2006: Message edited by: Andy Smith ]
 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any UPdates, It has become really really urgent now....
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No they dont have any pop up blocker...

They are using IE browser > 5.5
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic