SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Jul 30, 2006, 12:02 #1
- Join Date
- Mar 2003
- Location
- UK
- Posts
- 245
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Google maps & Mutiple Domains but one site.
I have a site that uses 2 domains to forward to the IP no. (a .org.uk and .co.uk). The site uses the Google Map API for a map on the site, however the API key is locked to the individual domain (I do have two keys for both the domains). I found the following Javascript which is supposed to switch the key depending on the domain that is accessing the page.
Code:if (window.location.host == 'www.domain1.com') { document.write('<'+'script src="http://maps.google.com/maps?file=api&v=1&key=key/for/domain1" type="text/javascript">' + '<'+'/script>'); } else if (window.location.host == 'www.domain2.com') { document.write('<'+'script src="http://maps.google.com/maps?file=api&v=1&key=key/for/domain2" type="text/javascript">' + '<'+'/script>'); } else { alert("host ="+window.location.host); }
-
Jul 30, 2006, 23:05 #2
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
could it be that the if statements don't match the web urls?
what about
if(location.Url.indexOf('domain1.com')>-1)
{
// do your stuff.
}
-
Aug 2, 2006, 12:43 #3
- Join Date
- Mar 2003
- Location
- UK
- Posts
- 245
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by gRoberts
http://www.parksideactiongroup.org.u...tive-map3.html
-
Aug 2, 2006, 13:29 #4
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
firefox javascript console:
Error: GUnload is not defined
Source File: http://www.parksideactiongroup.org.u...tive-map3.html
Line: 1
Error: unterminated string literal
Source File: http://www.parksideactiongroup.org.u...tive-map3.html
Line: 8, Column: 24
Source Code:
document.write('<'+'script
Error: GOverlay is not defined
Source File: http://www.parksideactiongroup.org.uk/js/einsert.js
Line: 19
Error: GBrowserIsCompatible is not defined
Source File: http://www.parksideactiongroup.org.u...tive-map3.html
Line: 106
I'm trying to work out why your doing document.write('<'+'script when you can simply do document.write('<script.
Gav
-
Aug 3, 2006, 14:07 #5
- Join Date
- Mar 2003
- Location
- UK
- Posts
- 245
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I found the script on Google's support forum, as I am by no means a Javascript expert, and to be honest I don't have much clue about what the most parts of the script do.
Bookmarks