opening a new window and passing parameters

G

graphicsxp

Hi,

I know how to open a page in a new window (using window.location) and
passing parameters in the URL (?param1='bla'&param2='bla') but what I
want is to pass the paramters using the GET method. I don't have a
form on my page, I just don't want the parameters to be visible in the
URL.

How can I do that ?

Thanks
 
E

Erwin Moller

(e-mail address removed) schreef:
Hi,

I know how to open a page in a new window (using window.location) and
passing parameters in the URL (?param1='bla'&param2='bla') but what I
want is to pass the paramters using the GET method.

What you describe IS the 'GET' method.


I don't have a
form on my page, I just don't want the parameters to be visible in the
URL.

Then don't pass them in the URL.

You can let the new window ask the opening window for the details.
Something like this:
1) in the new window fire the onunload event and call a function
fetchInfo();
2) In fetchInfo you simply ask the opener to pass the info by calling an
appropriate function. eg:
function fetchInfo(){
var myInfo = opener.giveName();
}

and make that function in the opening document.

Regards,
Erwin Moller
How can I do that ?

Thanks


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
T

Thomas 'PointedEars' Lahn

I know how to open a page in a new window (using window.location)

You mean window.open(). Assignment to window.location (or calling
window.location.replace()) does _not_ open a new window or tab.
and passing parameters in the URL (?param1='bla'&param2='bla') but what I
want is to pass the paramters using the GET method.

You are using the (HTTP) GET method/command already; the parameters are part
of the request URI. Maybe you want to use the POST method/command instead?
I don't have a form on my page, I just don't want the parameters to be
visible in the URL.

That would have to be a POST request, where the request parameters can also
be part of the HTTP message body (and so do not need to be in the request
URI).

Since you don't want to use a form, you would need to use XHR
(XMLHttpRequest), and then insert the content the server responded with
somewhere. (What about users without client-side script support?)

Google is your friend. [psf 6.1]


PointedEars
 
G

graphicsxp

I know how to open a page in a new window (using window.location)

You mean window.open().  Assignment to window.location (or calling
window.location.replace()) does _not_ open a new window or tab.
and passing parameters in the  URL (?param1='bla'&param2='bla') but what I
want is to pass the paramters using the GET method.

You are using the (HTTP) GET method/command already; the parameters are part
of the request URI.  Maybe you want to use the POST method/command instead?
I don't have a form on my page, I just don't want the parameters to be
visible in the URL.

That would have to be a POST request, where the request parameters can also
be part of the HTTP message body (and so do not need to be in the request
URI).

Since you don't want to use a form, you would need to use XHR
(XMLHttpRequest), and then insert the content the server responded with
somewhere.  (What about users without client-side script support?)

Google is your friend. [psf 6.1]

PointedEars

Sorry guys, I meant window.open() and 'POST' indeed. So how do I open
a new window and pass it parameters using POST (and without using a
form) ? or is it not possible without a form ? Using XMLHttpRequest I
don't see how i'm going to do it since I need to open a new window
 
T

Thomas 'PointedEars' Lahn

graphicsxp said:
Thomas said:
I don't have a form on my page, I just don't want the parameters to be
visible in the URL.

That would have to be a POST request, where the request parameters can
also be part of the HTTP message body (and so do not need to be in the
request URI).

Since you don't want to use a form, you would need to use XHR
(XMLHttpRequest), and then insert the content the server responded with
somewhere.  (What about users without client-side script support?)

Google is your friend. [psf 6.1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...]

Please trim quotations to the parts you are actually referring to.
Sorry guys, I meant window.open() and 'POST' indeed. So how do I open
a new window and pass it parameters using POST (and without using a
form) ? or is it not possible without a form ? Using XMLHttpRequest I
don't see how i'm going to do it since I need to open a new window

You can try Erwin's suggestion, or you can open the new window, create a
new document in it, and insert the XHR response message body there.

RTFFAQ, RTFM, STFW.


PointedEars
 
J

Jorge

Hi,

I know how to open a page in a new window (using window.location) and
passing parameters in the  URL (?param1='bla'&param2='bla') but what I
want is to pass the paramters using the GET method.  I don't have a
form on my page, I just don't want the parameters to be visible in the
URL.

How can I do that ?

Thanks

The parameters can go in the URL, in the request headers or (if it's a
POST) in the body/payload.

•Using JS+XHR you can put them in the headers (be it a POST or a GET)
or in the body (if a POST), and/or in the URL (of course).
•Using a form you can put them in the body (if a POST) or in the URL
(a GET).
•Using a link only in the URL (a GET).

One way to do what you're asking for, from within another (new)
window, would be to insert (from the parent window) in the target
(new) window a <script> that does the XHR of your liking and then
rewrites its own contents.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top