473,666 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

De-activating windows using Javascript

How do I deactivate a window using Javascript. For example if I have
a window that opens up another window, how do I prevent the user from
clicking (doing anything) in the original window until the new window
has been closed. Any insight will help. Thank you very much in
advanced.
Jul 20 '05 #1
3 11607
Ivo
"Maria Bitsku" <mi************ @hotmail.com> wrote in message
news:90******** *************** ***@posting.goo gle.com...
How do I deactivate a window using Javascript. For example if I have
a window that opens up another window, how do I prevent the user from
clicking (doing anything) in the original window until the new window
has been closed. Any insight will help. Thank you very much in
advanced.


onblur="self.fo cus()" in the popup will bring it to the front whenever
another browser window is clicked. But user can still go to another program.
Ivo
Jul 20 '05 #2

"Maria Bitsku" <mi************ @hotmail.com> wrote in message
news:90******** *************** ***@posting.goo gle.com...
How do I deactivate a window using Javascript. For example if I have
a window that opens up another window, how do I prevent the user from
clicking (doing anything) in the original window until the new window
has been closed. Any insight will help. Thank you very much in
advanced.


Hi there,

The kind of window you refer to is usually called a "modal window" or "modal
dialog".

Using self.focus() in the popup window (as suggested by Ivo) is a possible
solution but not a very good one as:

1. It will not work very well with some browsers.

2. The popup window becomes obtrusive for other (non-browser or irrelevant
browser) windows as well.

3. You have to put this code in the popup window itself.

Trying to assign a handler function to the onblur event of the newly open
window (from the opener window) is still plagued with problems number 1 and
2.
Other solutions:
---------------

* In IE there is showModalDialog () which creates a perfect modal dialog for
you. There may be something similar in some other browsers but it is fair to
say that this kind of solution would not cover a lot of browser real estate.

* You can use something like the following which I just put together and
have not tested with many browsers but please tell us of the results if you
test it yourself. It should however cover a lot of browsers. Basically it
tries to block all access to the opener window and puts focus on the popup
instead:

<script>

//Should be at least mozilla and ie (maybe 4.0+) compatible.
//You can try other event combos.
//With Mozilla you can make the opener appear on top by clicking on its
chrome;
//this does not happen with IE 6.0 (and maybe older versions as well)

w = window.open("po pup.htm", "", "height=200,wid th=200");
window.onactiva te =
window.onfocus =
window.document .onfocus =
window.document .onactive =
window.document .onclick =
window.document .onmousedown =
window.document .body.onclick =
window.document .body.onmousedo wn =
window.document .body.onresizes tart =
window.document .body.onbeforea ctivate =
window.document .body.onfocusin =
window.document .body.onactivat e =
window.document .body.onbeforee ditfocus =
window.document .body.ondrag =
window.document .body.ondragsta rt =
window.document .body.onscroll =
window.document .body.onfocus =
window.document .body.onclick =
window.document .body.oncontext menu =
window.document .body.ondblclic k =
window.document .body.onselects tart =
//add or remove events as needed

w.onblur =

function(e){

if (!w.closed){

//cross browser event killing
if (e && e.cancelable){
e.preventDefaul t();
e.stopPropagati on();
}
else if (event){
event.returnVal ue = false;
event.cancelBub ble = true;
}

w.focus();
}
}
</script>
* You can use this other method that may however have adverse effects on
popups that contain elements that receive focus. This method is also fairly
CPU hungry. Additionally it will not prevent sneaky access to the opener
window/document elements (although with some effort, sneaky access may be
possible with the previous method as well). It may also have obtrusive
effects to working with other windows. However, its big plus is that it will
keep the popup on top no matter what (more appropriate if you are building
an underground site with lotsa unsolicited popups).

<script>

w = open("popup.htm ", "", "height=200,wid th=200");

setInterval("if (!w.closed) w.focus();", 100);

</script>

Overall I recommend solution number two. There are cases where such
solutions will cause annoying side-effects but in my experience there are
usually workarounds. Also note that the first script can probably be
appropriately tweaked if you wish to use it with older browsers (like
Netscape 4) as well.

Best regards to the American military!

Fotios
Jul 20 '05 #3

w.onblur =


This line should have been omitted. Just comment it out.

Cheers,
Fotios
Jul 20 '05 #4

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

Similar topics

2
2681
by: WebRod | last post by:
Bonjour, comment savoir en moins de 5 secondes (enfin rapidement quoi) combien de nouveaux messages non récupérés se trouvent dans une BAL sur une serveur POP3 (pas d'imap donc)???? (en sachant que lorsque l'on récupère les emails, on ne les supprime pas du serveur au fur et à mesure) Parceque OUTLOOK y arrive bien lui!!
2
3027
by: grigoo | last post by:
bonjour a tous je me presente a vous::: greg dit le grigoo sur le web ,,etudiant en bioinformatique a montreal et jusqu au cou dans notre language prefere....java. et biojava.. et je suis en un newbee dans ce domaine et me dit que l homme est bien peu de chose voici en definitive mon probleme>>> je construit une classe appele symbolListWithGap. dans celle j y mets un constructeur:::: symbolListWithGap qui recoit
0
463
by: Michael Dyson | last post by:
M. Michael DYSON DIRECTEUR-ADJOINT SOCIÉTÉ DE SÉCURITÉ SARL. TEL.00229 20 21 80 Cotonou République du Bénin Email:michaeldyson2005@latinmail.com Bonjour . Je sais que mon message sera d’une grande surprise quand t-il vous parviendra. Donc, je vous présente toutes mes excuses. Je vous écris sincèrement dans le but d’obtenir votre coopération et votre confiance pouvant
0
2232
by: Alejandro Scomparin | last post by:
FORMULACION, PREPARACION Y EVALUACION ECONOMICA Y FINANCIERA DE PROYECTOS DE TECNOLOGIA INFORMATICA (IT) en la UTN Inicia: 17 de Mayo. 19 hs Dirigido a Esta preparado para gerentes, jefes, líder de proyectos del área de IT de todo tipo de organizaciones, y para profesionales de
0
4289
by: Alejandro Scomparin | last post by:
FORMULACION, PREPARACION Y EVALUACION ECONOMICA Y FINANCIERA DE PROYECTOS DE TECNOLOGIA INFORMATICA (IT) en la UTN Inicia: 17 de Mayo. 19 hs Dirigido a Esta preparado para gerentes, jefes, líder de proyectos del área de IT de todo tipo de organizaciones, y para profesionales de
0
1481
by: gandalf | last post by:
Con motivo del enorme esfuerzo realizado para visitar la ciudad argentina de Córdoba, participar en la Reunión del MERCOSUR, en la clausura de la Cumbre de los Pueblos en la histórica Universidad de Córdoba y en la visita a Altagracia, la ciudad donde vivió el Che en su infancia y unido a esto asistir de inmediato a la conmemoración del 53 aniversario del asalto a los cuarteles Moncada y Carlos Manuel de Céspedes, el 26 de julio de 1953,...
1
1624
by: crow | last post by:
http://www.pagina12.com.ar/diario/elpais/1-72984-2006-09-14.html Por Miguel Bonasso Desde La Habana Me había preparado para verlo, pero la realidad fue mucho más fuerte. Incluso le llevaba de regalo un ordenador de viaje. Es decir una suerte de cartuchera de cuero argentino, que en su interior tiene espacios predeterminados para papeles, tarjetas, pasaje, pasaporte, anotaciones varias, todo lo que necesita un viajero. Sé muy bien que...
1
1520
by: gandalf | last post by:
CON LA PASION DE SIEMPRE HABLO DE CHAVEZ, DE LA MEDICINA CUBANA... Y DE SU PROPIA MUERTE Relato de la nueva gran batalla de Fidel El líder cubano mostró cómo evoluciona su recuperación en el encuentro con el diputado argentino. También elogió a Hugo Chávez por su lucha para ingresar al Consejo Permanente de la ONU y por aliarse a sectores medios para "hacer los cambios democráticamente" y mostró su preocupación por terminar de editar sus...
1
1627
by: Sebastien | last post by:
Bonjour, Je tient d'abort a m'excuser de poster cette demande ici, mais je ne vois pas tres bien ou fair cette demande, Je développe un logiciel de génération de code (Génération de Code VB et PHP), il est depuis longtemps très aboutie (utiliser en production sur de nombreux developpement interne y compris pour des grand compte, (Télé2,Osram,EstVideo, ...) et propose de nombreuse fonctionnalite inedite a ma connessance dans d'autre...
0
8448
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8783
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8640
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.