473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1677
ni**********@webinfo.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**********@webinfo.fi> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.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,scrollbars=1,location=0,statusbar=0,men ubar=0,resizable=1,width=548,height=482');");
}

function BBB(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "',
'toolbar=0,scrollbars=1,location=0,statusbar=0,men ubar=0,resizable=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**********************@g43g2000cwa.googlegroups .com>
, dated Sat, 3 Sep 2005 16:07:36, seen in news:comp.lang.javascript,
ni**********@webinfo.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,scrollbars")

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.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 5 '05 #5
<ni**********@webinfo.fi> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.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 "AAAWindowName" 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(Name, 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("AAA", URL, 482, 548);
createPopup("BBB", 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
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example...
6
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. ...
0
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...
18
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...
27
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 =...
2
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...
8
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...
5
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 ...
30
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
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.