possible to enter variables in the URL for javascript?

P

paulpaul

HI ALL,

the below is a very simple code using the google map api, what i 'd
like to do is to modify it a
bit, thus making people can enter a URL with the below #XCOOR and
#YCOOR and thus showing the location.

e.g. i hope ppl can type the URL
(http://geocities.com/lin/example.html?XCOOR=124&YCOOR=36) in browser
then they get the map.

Could anyone help? Thanks a lot.

Regards,
Lin

//---------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script
src="http://maps.google.com/maps?file=ap...dfghaffdasfagM8bRSBWqQLROJb4IljWC3nlEtgq-u7-Q"
type="text/javascript"></script>
</head>

<body>
<div id="map" style="width:240px; height: 320px"></div>
<script type="text/javascript">
//<![CDATA[


var map = new GMap(document.getElementById("map"));
map.setMapType(G_SATELLITE_TYPE);

map.centerAndZoom(new GPoint( #XCOOR, #YCOOR), 2);

//]]>
</script>
</body>
</html>
 
R

Randy Webb

paulpaul said the following on 3/12/2006 12:37 AM:
HI ALL,

the below is a very simple code using the google map api, what i 'd
like to do is to modify it a
bit, thus making people can enter a URL with the below #XCOOR and
#YCOOR and thus showing the location.

e.g. i hope ppl can type the URL
(http://geocities.com/lin/example.html?XCOOR=124&YCOOR=36) in browser
then they get the map.


alert(document.location.search);

And then parse out the XCOOR and YCOOR and append it to your function call.
 

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

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,829
Latest member
KimberAlli

Latest Threads

Top