473,789 Members | 2,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple problem

I have web page that contains two links.
link "a" and link "b". When I click on "a" a small window should pop
up. when I click on "b" another small window should pop up. So what you
should see now is the base window which contains links "a" and "b" and
two small pop-up windows "a" and "b". Now I can make the script to pop
up "a" and "b" but the problem is that they're not shown at the same
time.

Any suggestions????

Sep 3 '05 #1
6 1704
ni**********@we binfo.fi wrote:
I have web page that contains two links.
.... and a really vague subject link.
link "a" and link "b". When I click on "a" a small window should pop
up.
*Shudder*
when I click on "b" another small window should pop up.
Double shudder.

Popup windows are a bad idea >99% of the time. The solution is almost
certainly to stop using popups.
So what you should see now is the base window which contains links "a"
and "b" and two small pop-up windows "a" and "b". Now I can make the
script to pop up "a" and "b" but the problem is that they're not shown at
the same time. Any suggestions????


Send your main window to the back so it doesn't cover up either of the
popups.

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 3 '05 #2

<ni**********@w ebinfo.fi> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
I have web page that contains two links.
link "a" and link "b". When I click on "a" a small window should pop
up. when I click on "b" another small window should pop up. So what you
should see now is the base window which contains links "a" and "b" and
two small pop-up windows "a" and "b". Now I can make the script to pop
up "a" and "b" but the problem is that they're not shown at the same
time.


There's not much here to go by (some code would be nice) but the problem
sounds like one of focus.

When a window is given focus it's brought to the top of the stack. So this
seems like what's happening to you (each step indicates a change in focus):

1) Main window has focus. You click on "A".

2) The "A" popup window appears and is given focus (brought the top).

3) You click on "B" which gives the main window focus again. The main
window is brought to the top (probably sending the "A" window behind it).

4) The "B" popup window appears and is given focus (brought the top).

So, in this case you're left with current focus on the "B" window and a
window stack of "B" on top of Main and Main on top of "A"

Essentially to fix this the process of opening either popup window should
check to see if the other exists and give it focus at some point probably
giving the other popup focus first then returning it to the current popup).

You could do this when the popups are opened or, if the popups are
cooperative on each of their "window.onFocus ()" events (when a popup gets
focus it should give the other focus for an instant to bring it up to the
top).

Take a look at the reference for the Window object - specifically the
Windows.focus() method.

Post back if you're still having problems and I'll work up some sample
script.

Hope this helps,

Jim Davis
Sep 4 '05 #3
Okay thanks for you help. This is what I'm using:
function AAA(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL , '" + id + "',
'toolbar=0,scro llbars=1,locati on=0,statusbar= 0,menubar=0,res izable=1,width= 548,height=482' );");
}

function BBB(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL , '" + id + "',
'toolbar=0,scro llbars=1,locati on=0,statusbar= 0,menubar=0,res izable=1,width= 280,height=210' );");
}
what should I add here to make it work as you told??

Thanks again -- Nizze

Sep 5 '05 #4
JRS: In article <11************ **********@g43g 2000cwa.googleg roups.com>
, dated Sat, 3 Sep 2005 16:07:36, seen in news:comp.lang. javascript,
ni**********@we binfo.fi posted :
I have web page that contains two links.
link "a" and link "b". When I click on "a" a small window should pop
up. when I click on "b" another small window should pop up. So what you
should see now is the base window which contains links "a" and "b" and
two small pop-up windows "a" and "b". Now I can make the script to pop
up "a" and "b" but the problem is that they're not shown at the same
time.


I suspect that you may be using window.open with a constant second
parameter, so that each "new" window uses the same window as is already
popped.

I use, for example,

var Wndw = window.open("", "X"+ +new Date(),
"height=" + (14*Obj.Cnt+42) + ",width=" + (8*BoxX+20) +
",resizable,scr ollbars")

Pop-ups are often criticised; but there's nothing wrong with generating
them as a result of explicit user request.

I'm still wondering how best to calculate height and width so that that
window fits round <pre> text comprising Obj.Cnt rows and BoxX columns.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 5 '05 #5
<ni**********@w ebinfo.fi> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Okay thanks for you help. This is what I'm using:


I may be wrong here (I'm working from memory and I've got a lousy memory).

The first problem is that you need to know the names of your windows or have
a reference to them to do this - so the AAA function would need to know the
name or have a reference of the BBB window and vice versa. Since you're
window names are dynamically generated this will be harder than it would be
with static name - but it's not so difficult with references. Also you
should really get into the habit of using the var keyword for local
variables... you'll thank me later.

For now I'm just going to write a variable in the main page global scope
called "AAAWindowN ame" and "BBBWindowName" . But there are definately many,
many other ways to do this.

Are you actually using the generated name "page" + id? If not there's
really no need to eval this just to set the variable. I'm going to assume
that you're NOT and can just use the window name. For this purpose I'll
call it "page" + id just because it feels odd to have an numeric identifier
for this. Consider having your function return a reference to the new
window and use that instead.

There's no real need, from the code you have here, to have two functions -
the only difference is the width and height and they could be passed as
arguments to a generic "open window" funciton.

But let's start simply. Function AAA might look like this:

function AAA(URL) {

// First Generate the Window Name
var WinName = "page" + new Date().getTime( );

// Open the window, assign a reference to it to a local variable
var CurWindow = window.open(URL , WinName, ' ... window stuff...);

// Add a reference to the window the main page.
AAAWindow = CurWindow;

// Now adjust focus, if needed, of the other window
// First we must check to see if the other variable has actually
been defined
if ( typeof BBBWindow == 'object' ) {
// Give the BBBWindow focus via the stored reference
BBBWindow.focus ();
};
// Now give THIS window focus to make sure it's still on top
CurWindow.focus ();

// Now return a reference to the window for use in the rest of the
application:
// If you need the name instead return "WinName" and use it.
return CurWindow;

};

That's good but let's make it more generic.

From what you've described I'm just not seeing the need to generate names of
the windows... let's, for a moment say, you don't need to. Let's also say
that you want to make this general enough to use with any number of windows
(I won't get into the interface issues there... but they definitely exist).
So, instead of single "AAAWindow" and "BBBWindow" variables we'll create a
hash map of window references.

// Create a new global object (our hash map)
PopupGroup = new Object();

// Create a generic createPopup function
function createPopup(Nam e, URL, height, width) {

// Open the window, assign a reference to it to a local variable
var CurWindow = window.open(URL , Name, ' ... window stuff - include
height and width...);

// Add a reference to the window to the hash map.
// You could also do this in the line above but I'm being methodical
here
PopupGroup[Name] = CurWindow;

// Now bring ALL popups in the group to the front
for ( Popup in PopupGroup ) {
PopupGroup[Popup].focus();
};

// Now give the newly created popup focus to make sure it's still on
top
CurWindow.focus ();

// Now return a reference to the popup for use in the rest of the
application:
return CurWindow;

};

To open your two windows here you might call the function like this:

createPopup("AA A", URL, 482, 548);
createPopup("BB B", URL, 210, 280);

To then access them in the rest of the application you could use:

PopupGroup["AAA"] or PopupGroup["BBB"]

For example:

PopupGroup["AAA"].document.write ("Hello!");

Personally I always lean towards organizing things like this... it makes
life a lot simpler (I think).

Hope this helps,

Jim Davis

Sep 5 '05 #6
Thanks a lot every body.. especially Jim!

Sep 9 '05 #7

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

Similar topics

3
3700
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example program #include <list>
6
2158
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I don´t know much javascript so I wrote a very simple one to validate a form I have on my webpage. could you please have a look at the following script: ------------------------------------------------------------
0
1898
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I have run into is that the emitted html at the end of the process is slightly different and doesn't work. Please don't be put off by all the source code. All the guts are in this first base class, and it doesn't do much. The rest is trivial...
18
1515
by: Sender | last post by:
Yesterday there was a very long thread on this query. (You can search on this by post by 'sender' with subject 'Simple Problem' post date Oct 7 time 1:43p) And in the end the following code was decided to open a new form: ---Code in the click event of a button: button1 if frm is nothing then frm = new form2() frm.show
27
4624
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res = $doc->loadHTMLFile("./aBasicSearchResult.html"); if ( $res == true ) { $zip = $doc->getElementById('zipRaw_id')->value; if ( 0 != $zip ) {
2
5186
by: Vitali Gontsharuk | last post by:
Hi! I have a problem programming a simple client-server game, which is called pingpong ;-) The final program will first be started as a server (nr. 2) and then as a client. The client then sends the message "Ping" to the server, which reads it and answers with a "Pong". The game is really simple and the coding should be also very simple! But for me it isn't. By the way, the program uses datagram sockets (UDP). And, I'm using
8
3559
by: rdrink | last post by:
I am just getting into pysqlite (with a fair amount of Python and MySQL experience behind me) and have coded a simple test case to try to get the hang of things... yet have run into a 'stock simple' problem... I can create a database 'test.db', add a table 'foo' (which BTW I repeatedly DROP on each run) with one INTGER column 'id', and can insert data into with: cur.execute("INSERT INTO foo (id) VALUES (200)") con.commit()
5
1885
by: Chelong | last post by:
hey,the follow is the text file content ========================================apple====pear== one Lily 7 0 0 7 7 two Lily 20 20 6.6666 20 8 one Lily 0 10 2.85 4 0 two Lily 22 22 7.33326 2 5 two jenny 6 0 0 6 6 two jenny 12 0 0 12 12 three jenny 36 36 10.26 36 36
30
3549
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
9511
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
10410
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...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7529
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
6769
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();...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4093
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
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.