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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Google Maps API: How to grab the domain of the html that loads script

Status
Not open for further replies.

jpo245

Programmer
Jan 16, 2005
45
US
Hi everyone, in order to insert a Googlemap into my php script, I have to insert the following <script> </script> from google.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
  <head>
    <script src="[URL unfurl="true"]http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAMmQqgY[/URL]
5iaKLIJRNgSvLWExT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSrRSx3e-PjL-
lsF9wQWNXG5amDGw" type="text/javascript"></script>
  </head>
  <body>
    <div id="map" style="width: 500px; height: 400px"></div>
    <script type="text/javascript">
    //<![CDATA[
    
    var map = new GMap(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
    
    //]]>
    </script>
  </body>
</html>


Basically, what happens, is that I sign up for an API key (that long hashed thingy in the above code), and each API key is valid for a single domain.

My question, is how is google able to extract the DOMAIN from which the referring html file is from?


For example, if
Has this line:

<script src="5iaKLIJRNgSvLWExT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSrRSx3e-PjL-
lsF9wQWNXG5amDGw" type="text/javascript"></script>

Google will know that is the calling domain.

The only way i know how to grab this is by using JS's location.href, however, assuming a PHP file serves up the JS, i do not know how to obtain the referring domain.

Appreciate any help.. Thanks!
 
My question, is how is google able to extract the DOMAIN from which the referring html file is from?

There are many ways they could do it, and the code would be different depending on the server-side technology they use. If you need to know the exact method, you should probably send them an email and see if they'll let you know.

Dan




[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top