473,386 Members | 1,644 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,386 software developers and data experts.

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('../quotescreenwindow.php?enroll_id=enrollwindowprime. php',
'WindowC', 'width=750,height=800,scrollbars=yes');">

In the new window that just opened called quotescreenwindow.php, I
have a button that when clicked, should open yet another window called
enrollwindowprime.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 4373
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('../quotescreenwindow.php?enroll_id=enrollwindowprime. php',
'WindowC', 'width=750,height=800,scrollbars=yes');">

In the new window that just opened called quotescreenwindow.php, I
have a button that when clicked, should open yet another window called
enrollwindowprime.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=enrollwindowprime.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.search != null
&& self.location.search.length 0 )
{
var strQuery = self.location.search.substring( 1 );

var astrQueries = strQuery.split( "&" );
for ( var index = 0; index < astrQueries.length; 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 htstrQueryString = getQueryString();
var strUrl = htstrQueryString[ "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.toString().split('=')[1];

HTML :

<button value="Next"
onclick="
truc=window.open('','','width=300,height=300,resiz able=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*********************@wanadoo.fr.invalidwrote :
>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.toString().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.open('','','width=300,height=300,resiz able=1');
truc.location='../'+newFile;">
My code looks like this:
<a href="#" onClick="window.open('enrollwindow.php', 'WindowD',
'width=750,height=900,scrollbars=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('enrollwindow.php', 'WindowD',
'width=750,height=900,scrollbars=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('../quotescreenwindow.php?enroll_id=enrollwindowprime. php',
'WindowB', 'width=750,height=800,scrollbars=yes');">

with enroll_id=enrollwindowprime.php 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 'quotescreenwindow.php'

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

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

- newFile
is a variable (global)

- self.location.toString().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 = 'enrollwindowprime.php';
The link's onclick :
truc = window.open('','','width=750,height=800,scrollbars =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 'enrollwindowprime.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.toString().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 = 'enrollwindowprime.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,height=800,scrollbars =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(newFile,'','width=750,height=800,scrol lbars=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.toString().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.search.split('=')[1];
>result :
from now, javascript knows the next file to call
newfile = 'enrollwindowprime.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.location.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,height=800,scrollbars =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(newFile,'','width=750,height=800,scrol lbars=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
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...
1
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...
1
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...
4
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
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...
1
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...
1
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....
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...
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...
0
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,...
0
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...

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.