473,667 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pass url to a popup

In my program the user clicks on a link and using the window.open
function, opens a new window.

I pass a url to the new window like this:

<a href="#"
onClick="window .open('../quotescreenwind ow.php?enroll_i d=enrollwindowp rime.php',
'WindowC', 'width=750,heig ht=800,scrollba rs=yes');">

In the new window that just opened called quotescreenwind ow.php, I
have a button that when clicked, should open yet another window called
enrollwindowpri me.php (this is the variable I am passing after the
question mark).

What I cannot do, is to grab this variable that I am passing to the
first window I open and use its content to open the next window.

I am not very experienced and have been piecing this together from
various web sites.

To simplify all of this:

Screen A Opens Popup Window B and passes it a variable with a url
inside of it.

Popup Window B wants to use the variable with the url to open Pop Up
Window C.

I would really appreciate some help.
Sep 6 '06 #1
6 4388
Hi,

Ellie wrote:
In my program the user clicks on a link and using the window.open
function, opens a new window.

I pass a url to the new window like this:

<a href="#"
onClick="window .open('../quotescreenwind ow.php?enroll_i d=enrollwindowp rime.php',
'WindowC', 'width=750,heig ht=800,scrollba rs=yes');">

In the new window that just opened called quotescreenwind ow.php, I
have a button that when clicked, should open yet another window called
enrollwindowpri me.php (this is the variable I am passing after the
question mark).
In a window, you can access the query string using location.search . This
property of the Location object is a string. What's a bit confusing is
that location.search returns "?enroll_id=enr ollwindowprime. php"
(including the leading question mark), so you must remove it yourself
using substring.

Here is a generic function returning the query string as a "hashtable" .

function getQueryString ()
{
var htstrQuery = new Object();

if ( self.location
&& self.location.s earch != null
&& self.location.s earch.length 0 )
{
var strQuery = self.location.s earch.substring ( 1 );

var astrQueries = strQuery.split( "&" );
for ( var index = 0; index < astrQueries.len gth; index++ )
{
var astrKeyValue = astrQueries[ index ].split( "=" );
var strValue
= ( ( astrKeyValue[ 1 ] == null )
? "" : astrKeyValue[ 1 ].toString() );

htstrQuery[ astrKeyValue[ 0 ].toString() ] = strValue;
}
}
return htstrQuery;
}
And then you can use:

var htstrQueryStrin g = getQueryString( );
var strUrl = htstrQueryStrin g[ "enroll_id" ];

if ( strUrl != null )
{
// Open your new window.
}

<snip>

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 6 '06 #2
ASM
Ellie a écrit :
>
To simplify all of this:

Screen A Opens Popup Window B and passes it a variable with a url
inside of it.

Popup Window B wants to use the variable with the url to open Pop Up
Window C.
For your particular need (only 1 variable),
in your file displayed in window B

JS in head :

var newFile = self.location.t oString().split ('=')[1];

HTML :

<button value="Next"
onclick="
truc=window.ope n('','','width= 300,height=300, resizable=1');
truc.location=' ../'+newFile;">
--
Stephane Moriaux et son [moins] vieux Mac
Sep 6 '06 #3
On Wed, 06 Sep 2006 12:05:53 +0200, ASM
<st************ *********@wanad oo.fr.invalidwr ote:
>Ellie a écrit :
>>
To simplify all of this:

Screen A Opens Popup Window B and passes it a variable with a url
inside of it.

Popup Window B wants to use the variable with the url to open Pop Up
Window C.

For your particular need (only 1 variable),
in your file displayed in window B

JS in head :

var newFile = self.location.t oString().split ('=')[1];
Again, I am not well versed in all of this. So, this would go in the
head of Window B? It just automatically picks up the variable I sent
attached to the url?
>
HTML :

<button value="Next"
onclick="
truc=window.ope n('','','width= 300,height=300, resizable=1');
truc.location=' ../'+newFile;">
My code looks like this:
<a href="#" onClick="window .open('enrollwi ndow.php', 'WindowD',
'width=750,heig ht=900,scrollba rs=yes');">

I tried to put your code in this statement but it opens up a blank
page. I don't understand where in the process it finds the variable I
sent it. I never refer to the variable name in Window B.

Sep 6 '06 #4
ASM
Ellie a écrit :
>
My code looks like this:
<a href="#" onClick="window .open('enrollwi ndow.php', 'WindowD',
'width=750,heig ht=900,scrollba rs=yes');">
Here, in your code, 'WindowD' is html name of the popup
You'l use it thru html code : target="WindowD "
It is of no interest in JavaScript (JS doesn't know this WindowD)
I tried to put your code in this statement but it opens up a blank
page. I don't understand where in the process it finds the variable I
sent it. I never refer to the variable name in Window B.
We have window (A) with file ie :'ellie.php'
contains

<a href="#"
onClick="window .open('../quotescreenwind ow.php?enroll_i d=enrollwindowp rime.php',
'WindowB', 'width=750,heig ht=800,scrollba rs=yes');">

with enroll_id=enrol lwindowprime.ph p after ? in called url

So, from window (A) you'l open a new popup (B)
with a target of no utility named WindowB
an displaying file 'quotescreenwin dow.php'

This file 'quotescreenwin dow.php' in popup (B)
only needs to catch from it's self url what is after '='
in order to can open next popup (C)
'quotescreenwin dow.php' will be something as :

<html>
<head>
<script type="text/javascript">
var newFile = self.location.t oString().split ('=')[1];
</script>
</head><body>
<a href="#"
onclick="
truc = window.open('', '','width=750,h eight=800,scrol lbars=1');
truc.location = newFile;
return false;"Popup C </a>
</body></html>
explain :
while downloading the file 'quotescreenwin dow.php' in window (B)
browser's javascript will immediately read
newFile = self.location.t oString().split ('=')[1];

- newFile
is a variable (global)

- self.location.t oString().split ('=')[1]
translation :
url of displayed file in present window considered as a string
then, using '=' as separator, extract second element

result :
from now, javascript knows the next file to call
newfile = 'enrollwindowpr ime.php';
The link's onclick :
truc = window.open('', '','width=750,h eight=800,scrol lbars=1');
truc.location = newFile;
return false;

- truc will be javascript name of the new popup window (C)
(empty window on this instant)

- truc.location = newFile;
url called in window 'truc' to display is newFile
that's to say 'enrollwindowpr ime.php'

- return false;
to stop the href of link

--
Stephane Moriaux et son [moins] vieux Mac
Sep 7 '06 #5
ASM wrote:
<snip>
- self.location.t oString().split ('=')[1]
translation :
url of displayed file in present window considered as a string
then, using '=' as separator, extract second element
There is nothing to say that a - location - object will have a -
toString - method (and while Windows IE 5 has a - toString - method on
its - location - object, calling it throws an exception), but very good
reason to expect it to have a string type - href - property (and indeed
a string type - search - property), which would be a better subject for
a - split - method call.
result :
from now, javascript knows the next file to call
newfile = 'enrollwindowpr ime.php';
URI encoding the resource path/name prior to adding it to the query
string, and URI decoding during extraction, would be a good idea.
The link's onclick :
truc = window.open('', '','width=750,h eight=800,scrol lbars=1');
Non-resizable windows are not a very good idea as if the size does not
suite the user they will not be able to re-size, while if the size is
suitable they will not suffer for being able to.
truc.location = newFile;
return false;

- truc will be javascript name of the new popup window (C)
(empty window on this instant)
<snip>

Why not:-

truc = window.open(new File,'','width= 750,height=800, scrollbars=1');
return false;

- and have the resource loaded directly into the new window (assuming it
is not pop-up blocked)?

Richard.
Sep 7 '06 #6
ASM
Richard Cornford a écrit :
ASM wrote:
<snip>
>- self.location.t oString().split ('=')[1]
translation :
url of displayed file in present window considered as a string
then, using '=' as separator, extract second element

There is nothing to say that a - location - object will have a -
toString - method (and while Windows IE 5 has a - toString - method on
its - location - object, calling it throws an exception), but very good
reason to expect it to have a string type - href - property (and indeed
a string type - search - property), which would be a better subject for
a - split - method call.
By my experience, never I got error with this code above.
However, you're probably right and it could be better to use search

newFile = self.location.s earch.split('=' )[1];
>result :
from now, javascript knows the next file to call
newfile = 'enrollwindowpr ime.php';

URI encoding the resource path/name prior to adding it to the query
string, and URI decoding during extraction, would be a good idea.
In this case, as newFile is to use to call a file, not necessary

newFile = unescape(self.l ocation.search. split('=')[1]);

(my browsers are too much clever, they automaticaly encode url in
location bar)
>The link's onclick :
truc = window.open('', '','width=750,h eight=800,scrol lbars=1');

Non-resizable windows are not a very good idea as if the size does not
suite the user they will not be able to re-size,
and he can't scroll, he no more find window lifts ? :-)
truc = window.open(new File,'','width= 750,height=800, scrollbars=1');
I think OP knew that, my example was more to show difference about
window name in JS and in html
(assuming it is not pop-up blocked)?
of course :-)
--
Stephane Moriaux et son [moins] vieux Mac
Sep 7 '06 #7

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

Similar topics

3
2891
by: Treetop | last post by:
I would like to pass text to a popup window to save creating a new html file for each help topic. I would like to have a value for the heading, a value for the text, code for printing the help page, and code to close the window. ------------------------------------------ the help window code is following <SCRIPT LANGUAGE="JavaScript"> <!-- Begin
1
2729
by: William Starr Moake | last post by:
The browser-based WYSIWYG editor I'm developing has a popup window with a form that generates table code from user input (width, border, cols, rows, bgcolor.) But the user has to copy-paste the generated table HTML into the editor window as it works now. How do I pass the form-generated HTML directly to the editor window so copy-paste is not necessary? I know I have to set focus on the editor window in the generate table code function, but...
1
12986
by: TErnst | last post by:
Hello All.... What I am attempting to do is have a link/button on a page (testpopup.cfm) that opens a popup page (popupwindow.cfm). The popup page displays a resultset from a query and the selected record needs to be passed through a query string/URL parameter to the original calling page and will be available in the body onload event of the calling page. I open the popup window and display the query results, I then click on
4
1895
by: rovisoft | last post by:
Does anybody know how to pass a popup blocker to let popup windows and redirects work? Thanks,Ovidiu ----------------------------------- http://www.DevPlug.com -- Connecting Developers
2
1610
by: Marco Antonio Montalvo Durán | last post by:
hi for example, I have a page 'register.aspx' and open a second page 'popup.aspx', what I want to do is to pass the control and values obtained in 'popup.aspx' to 'register.aspx', somebody help!!! thanks
1
1253
by: desmcc | last post by:
I am launching a popup screen in Javascript using window.ShowmodalDialog. Is there any easy way I can pass viewstate data (which is a class containing various members) into the popup. I also need to be able to pass the data back out of the popup so that the viewstate of the original page gets updated. thanks for the help, Des.
1
1751
by: kebabkongen | last post by:
Hi, I am working on an application where I make a popup window with a long list of users (with checkboxes) I am trying to figure out how to pass the list of selected users to the parent window. I have seen this be done by one field, such as "date pickers" from a calendar popup. Can anyone please give me a pointer to how I place the parameters from the popup window in the parent window?
1
9358
by: colleen1980 | last post by:
Hi: Can any one please tell me that how to i pass the two textbox values in the new page. If i use the form action in the popup window page then the new page is open in the same popup window as i need to open the new page in the main page window with passing the two textbox parameters into the new page. Program opens the new page but dont know how to pass the two textboxes values into the new page name deceasedToday.asp Needs help in...
0
8459
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
8367
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
8889
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
8650
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
5677
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
4202
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
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2781
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
2017
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.