I keep getting a GMap2 is undefined within my code: //////// <html> <head> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAUFhArcoq..." type="text/javascript"></script> <script type="text/javascript"> function aaa() { var newwin = window.open('','','scrollbars=no,menubar=no,height=600,width=800,resizable= yes,toolbar=no,location=no,status=no');
The way it works is the main window makes the standard JS script call for Google Maps. Once the page has loaded the onload event is fired to present the state of GMap2. It is defined successfully.
Now when i click the button on the page, it opens a new window and uses document.write to write a new <script> tag to call google maps for the new window. This is where the error occurs. Once the new window's onload event fires GMap2 is now undefined and remains that way. On inspection of the HTTP requests being made between both windows I notice the main window makes an additional call to:
which the popup window never does. Both windows do make a successful call the the <script src> though.
I am using IE6 under Windows XP. I am using a valid API and as you can see v=2. I suspect Javascript is doing something odd here but would like a javascript fix as opposed to loading a seperate .html file.
The aforementioned code is all there is. If you can makeit work then thats what i want. So far a tip came in stating to use DEFER within the script element. It helped but the google maps display still shows nothing (less the error message)
Yes, but when you post a link others can run the page through javascript debuggers and see what's going on. It's much more efficient than manually parsing through a boatload of code like that.
Please post a link, you'll get a faster and more accurate response.
Youre exactly right Tom. Here is the URL: http://www.spunge.org/~tony/misc/testpopup.htm When you click the Do Popup button it opens a new window and performs a document.write to fill the window with <script> info for google maps and other elements basically replicating the previous window. The window reveals nothing, not even an alert() will popup. Im unable to view its source in either FF or IE. I made some modifications to the script by adding DEFER and <script></script> within document.write.
Ok Im still messing around within the popup window. I've placed a setInterval in onload for the body and notice GMap2 remains undefined. However when i do a page refresh on the popup, NOW google maps shows it self and GMap2 == function. Just wanted to pass this info on to you. I still dont see how my dynamic html output can benefit.
I've posted another page that simply cuts to the chance and pops up a new window but uses the createElement / appendChild approach to build all the tags. Still no Google Maps.