Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #21464 > unrolled thread

How do I pass a query string when I use window.open when url is blank

Started by"Tony Johansson" <johansson.andersson@telia.com>
First post2013-09-29 18:01 +0200
Last post2013-09-29 11:04 -0700
Articles 3 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  How do I pass a query string when I use window.open when url is blank "Tony Johansson" <johansson.andersson@telia.com> - 2013-09-29 18:01 +0200
    Re: How do I pass a query string when I use window.open when url is blank Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-09-29 17:58 +0100
    Re: How do I pass a query string when I use window.open when url is blank Danny <dann90038@gmail.com> - 2013-09-29 11:04 -0700

#21464 — How do I pass a query string when I use window.open when url is blank

From"Tony Johansson" <johansson.andersson@telia.com>
Date2013-09-29 18:01 +0200
SubjectHow do I pass a query string when I use window.open when url is blank
Message-ID<l29isb$o9a$1@dont-email.me>
I just want to pass name, tourist or business and seatnr as a query string 
to a new url that is blank.
If the url has a specified sring like test.html then I know how to do.
I have google for this but havent't found any example.
is it possible to do that.
function OpenWindow()
{
    myWindow = window.open("", '', 'width=300,height=200');
    myWindow.document.write("<p>This is 'myWindow'</p>");
    myWindow.focus();
}

//Tony 

[toc] | [next] | [standalone]


#21465

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2013-09-29 17:58 +0100
Message-ID<0.89201dcb34b05ca86308.20130929175842BST.87txh3tvi5.fsf@bsb.me.uk>
In reply to#21464
"Tony Johansson" <johansson.andersson@telia.com> writes:

> I just want to pass name, tourist or business and seatnr as a query
> string to a new url that is blank.
> If the url has a specified sring like test.html then I know how to do.
> I have google for this but havent't found any example.
> is it possible to do that.
> function OpenWindow()
> {
>    myWindow = window.open("", '', 'width=300,height=200');
>    myWindow.document.write("<p>This is 'myWindow'</p>");
>    myWindow.focus();
> }

I am not exactly sure what you want.  Just putting the query string
(with its leading '?') as the URL opens a window with the current
window's URL but with its query string (if any) replaced the one
specified.  Is that what you want?

I don't know to what extent this behaviour is universal or mandated by
standards, but there are people here who can advise on such things.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#21466

FromDanny <dann90038@gmail.com>
Date2013-09-29 11:04 -0700
Message-ID<25dfc384-34d3-47e2-bf79-213c0146c02c@googlegroups.com>
In reply to#21464
To Tony

you could pass some .html url with querystrings in it to window.open() and that'd work
just fine, if that's what you mean


function ow{
			var mywindow = window.open('test.html?name=arthur&cust_type=business&seat_no=77');
			var passed_args = mywindow.location.search.substring(1) // to remove the "?" character
			var pairs = passed_args.split('&');
			var client {name : pairs[0].lastIndexOf('=')+1;
						type : pairs[1].lastIndexOf('=')+1;
						seat : pairs[2].lastIndexOf('=')+1;
						}
			// then you can stick it on say some span with id="whatever" at the new window
			mywindow.document.getElementById('whatever').innerHTML = 'Hello '+ client.name + ' your '+ client.type + ' seat is ready, and will be at ' + client.seat;
		}

keep in mind that loading the .html and accessing it, is subject to Same-Origin Policy

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web