Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieving the text from url 1

Status
Not open for further replies.

Pete222

Programmer
Dec 29, 2002
85
0
0
GB
Im making a webpage that needs to retrieve some text from the URL e.g. page.html?text=hello i know you can do it in Php but is there a way of doing it in javascript?

Pete.

Spend £20 and receive your 100% free, sim-free mobile phone. Get it now at (brand new website; join now and be top of the lists)
 
Yeah, and there should be plenty of examples if you have a bit of a search around.

Here's another example:
Code:
<script type="text/javascript">

// Assume query string of ?text=hello

window.onload = function() {

	server_variables = location.search.substring( 1 ).split( "&" );
	get = new Array();

	for( i=0; i < server_variables.length; i++ ) {

		pair = server_variables[ i ].split( "=" );
		get[ pair[ 0 ] ] = unescape( pair[ 1 ] );
	}

// To access the values: get[ 'text' ] e.g.
// alert( get[ 'text' ] );

}
	
</script>
 
See faq216-5442

--Chessbot

"So it goes."
Kurt Vonnegut, Slaughterhouse Five
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top