473,804 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using dynamic variable as window name and detecting if window exists

I am trying to create popup windows with dynamic variable names and
then see if they exist or not.

For example, if I call the function like so openWin("2600", "2000") I
would like the function to create a window called
"win2600200 0". I have tried the following code (and many other
variations) but I cannot get it to work

function openWin(senderI D, recipientID)
{
//Create the window if it does not exist or it has been closed
if (typeof "win" + senderID + recipientID=="u ndefined" || "win" +
senderID + recipientID.clo sed)
{
"win" + senderID +
recipientID=win dow.open("popup .aspx","win" + senderID +
recipientID,"to olbar=no,menuba r=no,width=350, height=350");
}
if("win" + senderID + recipientID)
{
//Do something with the window
}
}
thanks,

Luis

Jun 25 '07 #1
2 3910
ASM
lr******@gmail. com a écrit :
I am trying to create popup windows with dynamic variable names and
then see if they exist or not.
For example, if I call the function like so openWin("2600", "2000") I
would like the function to create a window called
"win2600200 0". I have tried the following code (and many other
variations) but I cannot get it to work

function openWin(senderI D, recipientID) {
var W = window['win'+senderID+ recipientID];
if( typeof(W)=='und efined' || W.closed)
W = window.open('', 'win'+senderID+ recipientID,'wi dth=350,height= 350');
W.location = 'popup.aspx';
W.focus();
}

not tested ...
so perhaps :

function isWin(senderID, recipientID) {
return window['win'+senderID+ recipientID];
}
function openWin(senderI D, recipientID) {
if( typeof(isWin(se nderID, recipientID))== 'undefined' ||
isWin(senderID, recipientID).cl osed)
isWin(senderID, recipientID) = window.open('',
'win'+senderID+ recipientID,
'width=350,heig ht=350');
isWin(senderID, recipientID).lo cation = 'popup.aspx';
isWin(senderID, recipientID).fo cus();
}

--
Stephane Moriaux et son (moins) vieux Mac
Stephane Moriaux and his (less) old Mac already out of date
Jun 25 '07 #2
On Jun 25, 11:40 am, ASM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
wrote:
lrleb...@gmail. com a écrit :
I am trying to create popup windows with dynamic variable names and
then see if they exist or not.
For example, if I call the function like so openWin("2600", "2000") I
would like the function to create a window called
"win2600200 0". I have tried the following code (and many other
variations) but I cannot get it to work

function openWin(senderI D, recipientID) {
var W = window['win'+senderID+ recipientID];
if( typeof(W)=='und efined' || W.closed)
W = window.open('', 'win'+senderID+ recipientID,'wi dth=350,height= 350');
W.location = 'popup.aspx';
W.focus();

}

not tested ...
so perhaps :

function isWin(senderID, recipientID) {
return window['win'+senderID+ recipientID];}

function openWin(senderI D, recipientID) {
if( typeof(isWin(se nderID, recipientID))== 'undefined' ||
isWin(senderID, recipientID).cl osed)
isWin(senderID, recipientID) = window.open('',
'win'+senderID+ recipientID,
'width=350,heig ht=350');
isWin(senderID, recipientID).lo cation = 'popup.aspx';
isWin(senderID, recipientID).fo cus();

}

--
Stephane Moriaux et son (moins) vieux Mac
Stephane Moriaux and his (less) old Mac already out of date
I tried both functions you suggested but I'm geting the following
error:

Microsoft JScript runtime error: 'closed' is null or not an object

thanks,

Luis

Jun 25 '07 #3

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

Similar topics

1
4066
by: bill ramsay | last post by:
Dear all. I am using an existing hodge-podge of an application that runs on top of an Access database. This application dials up customer equipment, handshakes then downloads/uploads various bits of information in the access database. The original application is designed for some poor sod to sit there for hours and manually do the necessary.
12
3637
by: Frank Stephan | last post by:
Hi, im using Struts with nested tags for form validation. So I end up with form elements named like this risikenManuell.praemieNeu risikenManuell.praemieNeu .... I would like to do a calculation on the input values
2
11132
by: Hasan Ammar | last post by:
Is it possible to set up hotkeys using onkeypress? I know it can be done with the usual alphanumeric keys, but what about function keys? or using ctrl/alt combinations? Does anybody have a tutorial/guide?
13
9660
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
10
9818
by: Tom Szabo | last post by:
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!!
1
4013
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the live databases on the network. Is there a way, via code, when I get back in-house from being on the road to click a button, and select the backends I want to link to? I would want to delete all the current links and link to the "live"
5
38125
by: M B HONG 20 | last post by:
Hi all - Is there a way to completely destroy a javascript variable? I know of reloading the page, using variablex = null and delete variablex
14
2907
by: Ben | last post by:
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one statement. I first connect to the database... self.con = MySQLdb.connect(user=username, passwd =password) self.cursor = self.con.cursor() self.cursor.execute("SET max_error_count=0")
1
3887
by: faultykid | last post by:
I would like to store a variable then call it back later. I have a variable on line 198 www = ''+this._ad.clickUrl+''; and on line 321 i try document.write(www);
0
9710
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
9589
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
10593
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
10329
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,...
0
10085
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
6858
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
5527
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...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3830
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.