browser opens new windows or tabs

A

Andrew Poulos

Is there a way for javascript to know if a browser has been set to open
new windows in tabs? I'm trying to fix some code that allows a user to
close a window that javascript opened and it seems to get confused what
window to close when a new tab is opened. (The user clicks a link in the
opened window which which opens a new window and close the current one.)

Andrew Poulos
 
S

SAM

Andrew Poulos a écrit :
Is there a way for javascript to know if a browser has been set to open
new windows in tabs? I'm trying to fix some code that allows a user to
close a window that javascript opened and it seems to get confused what
window to close when a new tab is opened. (The user clicks a link in the
opened window which which opens a new window and close the current one.)

How do you do to close an opener ?
(supposed to be a main window which is not closable by JS)

Tabs react exactly as normal windows (in my Fx at least)

If the popup opened in a tab has a button to close it, it closes this
tab and you jump back to the tab of its opener.
 
J

Joost Diepenmaat

SAM said:
Andrew Poulos a écrit :

How do you do to close an opener ?
(supposed to be a main window which is not closable by JS)

Tabs react exactly as normal windows (in my Fx at least)

If the popup opened in a tab has a button to close it, it closes this
tab and you jump back to the tab of its opener.

Not to mention that opening unrequested new windows is one of the most
annoying things you can do. Just don't do it; use plain links and let
the user sort things out to his/her preference.
 
A

Andrew Poulos

Joost said:
Not to mention that opening unrequested new windows is one of the most
annoying things you can do. Just don't do it; use plain links and let
the user sort things out to his/her preference.

1. You don't know what I'm coding.
2. You don't know who I'm coding for
3. You don't know the window is not requested.
4. I was not asking for usability advice

It is typical (so much so that the behaviour is expected) for an LMS to
automatically launch a SCO in a new window.

Andrew Poulos
 
A

Andrew Poulos

SAM said:
Andrew Poulos a écrit :

How do you do to close an opener ?
(supposed to be a main window which is not closable by JS)

Tabs react exactly as normal windows (in my Fx at least)

If the popup opened in a tab has a button to close it, it closes this
tab and you jump back to the tab of its opener.
I'll check what is happening again but the window that is opened by
javascript which in turn opens a new window is supposed to close when
the new window is opened. Instead the new window is closing.

This is only happening in IE 7 that is set to open windows in tabs.

Andrew Poulos
 
T

The Natural Philosopher

Andrew said:
I'll check what is happening again but the window that is opened by
javascript which in turn opens a new window is supposed to close when
the new window is opened. Instead the new window is closing.

This is only happening in IE 7 that is set to open windows in tabs.

Andrew Poulos

I am fairly sure I have this working..any chance of sample code of your
window.open() stuff?

If you track the object that this returns, you can always close the
correct window.



Closing the original window is surely simply a URL jump..or did you mean
you want to open a NEW briowser window altogthere and close the earlier
window in a tabbed session?
 
L

Lasse Reichstein Nielsen

Andrew Poulos said:
Is there a way for javascript to know if a browser has been set to
open new windows in tabs?

No. Not even a way to know whether the browser supports more than
one open page at the time (e.g., WebTV).

In Opera, all pages are opened in a new window. However, those windows
are all contained in the main application window, maximized as
default, and are accessible using tabs. I.e., tabs and windows are the
same.
I'm trying to fix some code that allows a user to close a window
that javascript opened and it seems to get confused what window to
close when a new tab is opened. (The user clicks a link in the
opened window which which opens a new window and close the current
one.)

Show us the code. It shouldn't matter whether its tabs or windows.

/L
 
S

SAM

Andrew Poulos a écrit :
I'll check what is happening again but the window that is opened by
javascript which in turn opens a new window is supposed to close when
the new window is opened. Instead the new window is closing.

This is only happening in IE 7 that is set to open windows in tabs.


I haven't IE and following example works fine in my Fx using tabs :
(works too in iCab.3 and Opera.9)

file 'mother.htm' :
<html>mother :
<a href="#" onclick="daughter_1=window.open('daughter_1.htm');
return false;">popup 1</a>
</html>

file 'daughter_1.htm' :
<html>daughter_1 :
<a href="#"
onclick="opener.daughter_2=daughter_2=window.open('daughter_2.htm');
return false;">popup 2</a>
</html>

file 'daughter_2.htm' :
<html>
<body onload="mother=opener.opener;opener.close();">
daughter_2 :
<a href="#" onclick="mother.daughter_2.close();
return false;">complex self close</a>
</html>

the popup 2 on loading closes the popup 1
closing the popup 2 (using any way) -> back to mother
 
A

Andrew Poulos

Lasse said:
No. Not even a way to know whether the browser supports more than
one open page at the time (e.g., WebTV).

In Opera, all pages are opened in a new window. However, those windows
are all contained in the main application window, maximized as
default, and are accessible using tabs. I.e., tabs and windows are the
same.


Show us the code. It shouldn't matter whether its tabs or windows.
The code is quite ordinary

// launch the course (str sets the default height and width)
myWin = window.open("ind.htm","myCourse", str);
// close the launch page
window.close();
// if you can't close the launch page go to the blank page
setTimeout("self.location.replace('blank.htm')",600);

I'm starting to think its a bug in early releases of IE 7 that was fixed
in later releases.

Andrew Poulos
 
S

SAM

Andrew Poulos a écrit :
The code is quite ordinary

// launch the course (str sets the default height and width)
myWin = window.open("ind.htm","myCourse", str);
// close the launch page
window.close();
// if you can't close the launch page go to the blank page
setTimeout("self.location.replace('blank.htm')",600);

I'm starting to think its a bug in early releases of IE 7 that was fixed
in later releases.

// launch the course (str sets the default height and width)
myWin = window.open('ind.htm','myCourse', str);
// close the launch page
self.close();
// if you can't close the launch page go to the blank page
if(!self.closed) {
setTimeout('self.location.replace(\'blank.htm\')',600);
myWin.focus(); }
 
T

Thomas 'PointedEars' Lahn

Andrew said:
The code is quite ordinary

// launch the course (str sets the default height and width)
myWin = window.open("ind.htm","myCourse", str);
// close the launch page
window.close();
// if you can't close the launch page go to the blank page
setTimeout("self.location.replace('blank.htm')",600);

There is nothing ordinary about it. For starters, it is based on the
misconception that code after the window.close() call is never executed.
I'm starting to think its a bug in early releases of IE 7 that was fixed
in later releases.

It is common knowledge that only windows opened with client-side scripting
can be closed with client-side scripting (any other behavior is a security
bug and therefore nothing that can be relied on). It is also common
knowledge that UA API calls like that of methods of the host object referred
to by `window' are not necessarily performed in an all-synchronous way. The
least that is required here is:

myWin = window.open("ind.htm", "myCourse", str);

// close the launch page
window.close();

// if you can't close the launch page go to the blank page
if (window && !window.closed)
{
window.setTimeout("window.location.replace('blank.htm')", 600);
}

Although I don't see the necessity of the window.setTimeout() call.

window.onerror or exception handling would serve better here if they were
universally supported.


PointedEars
 
J

Joost Diepenmaat

Andrew Poulos said:
1. You don't know what I'm coding.
Ok.

2. You don't know who I'm coding for

Do you? I don't know. I don't even know what you're coding.
3. You don't know the window is not requested.

If I don't expect a full-size new window, I don't want it. For one
thing, my window manager does not size windows like you probably
expect. It sure as hell doesn't size windows the way you request. And
full-size windows are easy to request, just use a target.
4. I was not asking for usability advice

Feel free to ignore me.
It is typical (so much so that the behaviour is expected) for an LMS
to automatically launch a SCO in a new window.

What's an LMS? What's an SCO (besides that highly suspect Unix vendor)?
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top