473,881 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return focus to same pop-up window repeatedly

I've only recently returned to (trying to) doing simple JS, so this is
probably a really lame question.

I have a Web page with a series of graphics in it (window A).

Clicking on a graphic in A opens a small pop-up window (window B) over A.

If the visitor clicks on B, it closes.

If the visitor clicks back on A -- the page or a new graphic -- A comes
to the forefront and hides B.

If B remains open (visitor does not click on it) and visitor clicks on
another graphic on A, the contents of B are replaced by whatever the new
link points to (or the same if the same graphic is clicked on).

I can make all the above happen. What I can't figure out is how to set
the focus back on B, so that it comes to the forefront, after clicking
on a graphic in A. I've messed around with focus() in all sorts of ways
but can't get B to come back to the foreground. My attempts include
adding a focus statement in the page loading (graphic.html in the
example below).

This is what works:

function secWin(url) {
window.open(url ,"imagePopUp"," width=270,heigh t=225,left=50,t op=50") ;
}

used as follows

<a href="javascrip t:secWin('graph ic1.html');"> image </a>

I hope someone can straighten this out for me. Thanks.
Jan 19 '06 #1
13 2288
Richard Shewmaker said the following on 1/19/2006 12:52 AM:
I've only recently returned to (trying to) doing simple JS, so this is
probably a really lame question.

I have a Web page with a series of graphics in it (window A).

Clicking on a graphic in A opens a small pop-up window (window B) over A.

If the visitor clicks on B, it closes.

If the visitor clicks back on A -- the page or a new graphic -- A comes
to the forefront and hides B.

If B remains open (visitor does not click on it) and visitor clicks on
another graphic on A, the contents of B are replaced by whatever the new
link points to (or the same if the same graphic is clicked on).

I can make all the above happen. What I can't figure out is how to set
the focus back on B, so that it comes to the forefront, after clicking
on a graphic in A. I've messed around with focus() in all sorts of ways
but can't get B to come back to the foreground. My attempts include
adding a focus statement in the page loading (graphic.html in the
example below).

This is what works:

function secWin(url) {
window.open(url ,"imagePopUp"," width=270,heigh t=225,left=50,t op=50") ;
var myWindowReferen ce = window.open(... );
myWindowReferen ce.focus();
}

used as follows

<a href="javascrip t:secWin('graph ic1.html');"> image </a>


http://jibbering.com/faq/#FAQ4_24


--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

Please quote what you are replying to.

If you want to post a followup via groups.google.c om, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

Jan 19 '06 #2
Randy Webb wrote:
Richard Shewmaker said the following on 1/19/2006 12:52 AM:
I've only recently returned to (trying to) doing simple JS, so this is
probably a really lame question.

I have a Web page with a series of graphics in it (window A).

Clicking on a graphic in A opens a small pop-up window (window B) over A.

If the visitor clicks on B, it closes.

If the visitor clicks back on A -- the page or a new graphic -- A
comes to the forefront and hides B.

If B remains open (visitor does not click on it) and visitor clicks on
another graphic on A, the contents of B are replaced by whatever the
new link points to (or the same if the same graphic is clicked on).

I can make all the above happen. What I can't figure out is how to set
the focus back on B, so that it comes to the forefront, after clicking
on a graphic in A. I've messed around with focus() in all sorts of
ways but can't get B to come back to the foreground. My attempts
include adding a focus statement in the page loading (graphic.html in
the example below).

This is what works:

function secWin(url) {
window.open(url ,"imagePopUp"," width=270,heigh t=225,left=50,t op=50") ;


var myWindowReferen ce = window.open(... );
myWindowReferen ce.focus();
}

used as follows

<a href="javascrip t:secWin('graph ic1.html');"> image </a>


http://jibbering.com/faq/#FAQ4_24


Hi. Thank you. That was one of the attempts I made (so I don't feel
quite so stupid now). I figured since you were giving it to me here that
it must work ... so my first suspect was my browser. And guess what?
That's the problem.

It works just fine in IE6, Opera 8 on Win32, but it does not work in
Firefox 1.5! Time for me to add a note to that effect on Mozillazine.
Jan 19 '06 #3
Randy Webb wrote :
Richard Shewmaker said the following on 1/19/2006 12:52 AM:
I've only recently returned to (trying to) doing simple JS, so this is
probably a really lame question.

I have a Web page with a series of graphics in it (window A).

Clicking on a graphic in A opens a small pop-up window (window B) over A.

If the visitor clicks on B, it closes.

If the visitor clicks back on A -- the page or a new graphic -- A
comes to the forefront and hides B.

If B remains open (visitor does not click on it) and visitor clicks on
another graphic on A, the contents of B are replaced by whatever the
new link points to (or the same if the same graphic is clicked on).

I can make all the above happen. What I can't figure out is how to set
the focus back on B, so that it comes to the forefront, after clicking
on a graphic in A. I've messed around with focus() in all sorts of
ways but can't get B to come back to the foreground. My attempts
include adding a focus statement in the page loading (graphic.html in
the example below).

This is what works:

function secWin(url) {
window.open(url ,"imagePopUp"," width=270,heigh t=225,left=50,t op=50") ;


var myWindowReferen ce = window.open(... );
myWindowReferen ce.focus();


Randy, if the window is new, there is no need to focus() it. The focus
call should be done only if the url is different.

What the OP needed is an example like this one (3rd one, last one):

http://developer.mozilla.org/en/docs...Best_practices

Also, the user must check the checkbox "Allow scripts to:Raise or lower
windows to" in Mozilla or Firefox. Same thing with Opera 8+.

Gérard
--
remove blah to email me
Jan 19 '06 #4
Richard Shewmaker wrote :
I've only recently returned to (trying to) doing simple JS, so this is
probably a really lame question.

I have a Web page with a series of graphics in it (window A).

Clicking on a graphic in A opens a small pop-up window (window B) over A.

If the visitor clicks on B, it closes.

If the visitor clicks back on A -- the page or a new graphic -- A comes
to the forefront and hides B.

If B remains open (visitor does not click on it) and visitor clicks on
another graphic on A, the contents of B are replaced by whatever the new
link points to (or the same if the same graphic is clicked on).

I can make all the above happen. What I can't figure out is how to set
the focus back on B, so that it comes to the forefront, after clicking
on a graphic in A. I've messed around with focus() in all sorts of ways
but can't get B to come back to the foreground. My attempts include
adding a focus statement in the page loading (graphic.html in the
example below).

This is what works:

function secWin(url) {
window.open(url ,"imagePopUp"," width=270,heigh t=225,left=50,t op=50") ;
If you do not set "resizable= yes" nor "scrollbars=yes " in the
windowFeatures string list, then the window will not be resizable and
will not render scrollbars if needed, if document box overflows
requested window dimensions.
}

used as follows

<a href="javascrip t:secWin('graph ic1.html');"> image </a>
Do not use "javascript :" in links. "javascript :" starting an href value
is widely known as an error. "javascript :" in links reduces
accessibility, usability of links, user features, browser preferences in
all tested browsers.

http://jibbering.com/faq/#FAQ4_24

Also
http://developer.mozilla.org/en/docs...ability_issues

I hope someone can straighten this out for me. Thanks.


Study the 3 examples, specially the 3rd example, at

Mozilla Developer Center on DOM:window.open
Best practices
http://developer.mozilla.org/en/docs...Best_practices

and you can have a look also at:

What does the "Raise or lower windows" setting do exactly?
http://www.gtalbot.org/Netscape7Sect...seLowerSetting

Your browser+user/pref settings must allow scripts to raise or lower
windows. This can be the case in Mozilla 1.x, Firefox 1.x and Opera 8+.

Gérard
--
remove blah to email me
Jan 19 '06 #5
Gérard Talbot said the following on 1/19/2006 3:33 AM:
Randy Webb wrote :
Richard Shewmaker said the following on 1/19/2006 12:52 AM:
<snip>

function secWin(url) {
window.open(url ,"imagePopUp"," width=270,heigh t=225,left=50,t op=50") ;
var myWindowReferen ce = window.open(... );
myWindowReferen ce.focus();


Randy, if the window is new, there is no need to focus() it. The focus
call should be done only if the url is different.


And that is it's purpose. To bring it back to the front when a second
page is attempted to be opened. If it is the first call, then the
focus() does no harm. But if it is the second call and the original
popup is behind the main window, it will bring it back to the front.
Unless the option is disallowed that you mention below.
What the OP needed is an example like this one (3rd one, last one):

http://developer.mozilla.org/en/docs...Best_practices
Also, the user must check the checkbox "Allow scripts to:Raise or lower
windows to" in Mozilla or Firefox. Same thing with Opera 8+.


That option I had forgotten about :)

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 19 '06 #6
to make a window having focus repeatedly:

var wind1 = window.open('.. .','...','...') ;
var timer1 = setInterval( wind1.focus, 500 );

I think this solve the problem.

Jan 19 '06 #7
Randy Webb wrote :
Gérard Talbot said the following on 1/19/2006 3:33 AM:
Randy Webb wrote :
Richard Shewmaker said the following on 1/19/2006 12:52 AM:
<snip>

function secWin(url) {
window.open(url ,"imagePopUp"," width=270,heigh t=225,left=50,t op=50") ;

var myWindowReferen ce = window.open(... );
myWindowReferen ce.focus();
Randy, if the window is new, there is no need to focus() it. The focus
call should be done only if the url is different.


And that is it's purpose. To bring it back to the front when a second
page is attempted to be opened. If it is the first call, then the
focus() does no harm.


It does no harm but it won't be needed. That's why I prefer a code fork
(like in the 3rd example of the "Best Practices" section of the url below)
so that resorting to a focus() call is only done when needed.
But if it is the second call and the original
popup is behind the main window, it will bring it back to the front.
Unless the option is disallowed that you mention below.
What the OP needed is an example like this one (3rd one, last one):

http://developer.mozilla.org/en/docs...Best_practices
Also, the user must check the checkbox "Allow scripts to:Raise or
lower windows to" in Mozilla or Firefox. Same thing with Opera 8+.


That option I had forgotten about :)


Gérard
--
remove blah to email me
Jan 19 '06 #8
Thank you, Randy, Gérard, & Leandro --

I have a little more info which is helpful in a general way.

In Firefox 1.5 the JavaScript option for "raise or lower windows" is
turned off by default, and that's what caught me.

In my case the window was the same size each time because it was
bringing up an alternate image and all of them were the same size.

Without the focus(), the pop-up window does not come back to the
forefront (on top of the parent window), and I suspect that is because
the parent window is getting the focus as the result of a visitor
clicking a new link on it. It helps to know that the main window was
whatever size your browser had and the pop-up was much smaller, and
depending on where the main one was, it could disappear completely
behind the main one when that one had another link selected.

I'll definitely check out the Web sites indicated -- as I said, I've not
been using JS for a long time and am basically starting almost at
scratch again (sigh).

Many thanks.
Jan 19 '06 #9
leandro camargo wrote:
to make a window having focus repeatedly:

var wind1 = window.open('.. .','...','...') ;
var timer1 = setInterval( wind1.focus, 500 );

I think this solve the problem.


You have not tested this, have you? It introduces more problems than it
solves.
PointedEars
Jan 20 '06 #10

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

Similar topics

47
3657
by: Martin DeMello | last post by:
It seems to be a fairly common pattern for an object-modifying method to return None - however, this is often quite inconvenient. For instance def f(lst1, lst2): g((lst1 + lst2).reverse()) # doesn't work! you need to say
7
10563
by: Chris | last post by:
I'm using eight links listed horizontally as a menu on my site. I'm using font-variant:small-caps and they are padded so that they mimic buttons. My gripe is with the way IE handles the focus rectangle on these links. It insists on drawing this crazy shape that traces the text, which with small caps looks rather assinine. Firefox handles the same task very gracefully (yeah Gecko!) and I would like to force IE to do the same. The site...
8
1924
by: Huibuh | last post by:
I start hating RETURN!!! list<happy> //#include <list>// is searched via iterator (ptr) so long until the argument "number" of the class "happy" is equal now. The function "findhappy" works fine, finds the right pointer "nownumber" with correct values. Behind "return" the memory address remains correct but the values are wrong (a huge negative number and all the same).
4
2201
by: Roger Withnell | last post by:
I want to validate the data entered into a form text field by calling a function with onblur, doing the validation and, if the input is invalid, giving an alert to the user and returning focus and select to the invalid field to force the user to correct the entry. A simple example is at www.brilley.co.uk/TestInfo.htm The problem is that this example works in IE but not in NN or Safari, which do not return focus or select back to the...
5
5640
by: Dave Brydon | last post by:
I'm checking for required fields, and using the code below, which I normally have no difficulties with; however, as a twist I decided to return the focus back to the specific field(s) in question for input. Under the "Case vbYes" I indicated the two required fields to return the focus, based on which one is empty, however, I cannot seem to return the focus. If I only have one field indicated in the code, example; If Me.txtUDateStart =...
32
8922
by: Mike Machuidel | last post by:
Hi, I'm a game developer programming mostly in C and ASM for about 7 years. Today at work a colleague (a C++ programmer) yelled at me I'm a bad C programmer because I use "return(0);" instead of "return 0;". He explained that "return" is not a function but a stament, like I didn't know already. The other colleagues also argreed with him :(. Can someone please explain what's so wrong about using "return" with
7
38854
by: Fernando | last post by:
Hello, I want call, from main program, to a function (with void arguments), what it run the function program and return the data of type char. I have make a example of code, by it don´t run, I can´t compile. I beleave what I have problems with the concept of the arrays and the pointers: #include <stdio.h> char composefile(void); main () { char uno;
25
1734
by: noe | last post by:
Hello, I'm writing a file system filter driver and I've found in an example this sentence: if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoRead )) { return (fastIoDispatch->FastIoRead)( FileObject, FileOffset, Length, Wait,
6
3509
by: Scotty | last post by:
Hi, I need some info How to return the value from the database My combobox Me.cboTypeAdres.Items.Add("Type Adres") Me.cboTypeAdres.Items.Add("Leverancier") Me.cboTypeAdres.Items.Add("Klant")
4
1446
by: vozzek | last post by:
(bad joke, I know) Alright, I'm an almost total java rookie, so please don't laugh (a snicker or chuckle would be okay I guess...) I've got a form (newloginform) with an E-mail field (new_email) that I'm validating with a very simple script. If the validation fails, the user gets the requisite error message, and the field is blanked out. This all works. The problem is, I want to return focus to the E-mail field AFTER the user clicks...
0
9927
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
11098
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
10717
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
10401
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...
0
9552
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7953
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
5977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
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
4196
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.