Solved

Google Javascript issues in Explorer 8 and Firefox

Posted on 2011-09-09
13
352 Views
Last Modified: 2012-05-12
The code below no longer works in Explorer 8 or Firefox. When I set compatibility mode it works.

Trying to add a point to a Google map and change the cursor to a "crosshair" to do so.

function Add_Point_Enable()
 {	
	//Allows user to add a new point to the map by clicking on the map
	alert('Move the cursor to the desired location');
	document.getElementById("datatable").style.display = "";
	document.getElementById("Cancel").disabled=false;
	map.getDragObject().setDraggableCursor("crosshair");
	GEvent.addListener(map, "click", function(marker, point) 
		{  
		 document.getElementById('currentid').value = "";
		 ChangeButtons();
			if (marker) 
			{    
				
			} 
			else 
			{    
				var confirmpoint = confirm("Do you want to add a signal to this location?");
				
				if (confirmpoint)
				{
					map.clearOverlays();
					GetData();
					map.addOverlay(new GMarker(point));
					ClearData();
					document.mapform.newlat.value = point.y;
					document.mapform.newlon.value = point.x;
					document.getElementById("Save").disabled=false;
					document.getElementById("Add").disabled=true;
					//document.getElementById("storydisplay").style.display = "none"; 
				} 
			}
		} // close of function(marker,point)
	); //close of listener
}

Open in new window

0
Comment
Question by:Alemus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 22

Expert Comment

by:Kim Walker
ID: 36512269
Please elaborate on "no longer works." Are you getting an error? Are you getting unexpected results?

Can you post a link to a page where this code is being used?
0
 
LVL 2

Author Comment

by:Alemus
ID: 36522716
The code is on a password protected page. This code is supposed to trigger a change in the cursor from the hand to a crosshair and allow the adding of points to a Google map.

when I say "no longer works", when i click the button that is supposed to trigger this even, nothing happens.

Right now I can post a link because the code is on a protected web site.
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 36522844
Are you certain that no error is being generated? In IE, you would see a message in the status bar at the bottom if you have the status bar turned on. In Firefox you can view the error console under the Tools menu.

Are you getting the alert to move the cursor to the desired location?
0
Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

 
LVL 2

Author Comment

by:Alemus
ID: 36523122
Yes the alert asking me to move the cursor i sappearing (line 4)

It looks like I actually am getting an error
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Mon, 12 Sep 2011 14:24:22 UTC


Message: 'document.getElementById(...)' is null or not an object
Line: 254
Char: 2
Code: 0
URI: http://www.nctcog.org/trans/data/tcins/trafficsignals/admintrafficsignals.asp


However, this error is occuring outside of the current function
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 36523586
Is line 254 one of the line is the above code? Check your spelling in the the getElementById arguments. IDs are case-sensitive.
0
 
LVL 2

Author Comment

by:Alemus
ID: 36524098
The spelling is correct but it points to an element ID assigned to a <TD>  I tried moving the ID to a <div> and that didn't seem to solve the problem.
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 36524126
Do you have two elements with the same ID?
0
 
LVL 22

Accepted Solution

by:
Kim Walker earned 500 total points
ID: 36524147
No. That can't be it; you wouldn't get the error "is null or not an object" if that was the case. Have you used a reserved word as an ID? What is the ID of the element line 254 is trying to get?
0
 
LVL 2

Author Comment

by:Alemus
ID: 36524704
The ID is "AddButtons".
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 36524782
This is perplexing. It would be easier if I could see the page. I'm sure you've checked your HTML and confirmed there is an element with the exact ID "AddButtons." Is it possible that element is inside the div that is consumed by the google map?
0
 
LVL 2

Author Comment

by:Alemus
ID: 36524844
I actually just found the problem and you set me on the right path by having me double check my element IDs.
It turns out I didn't have one mispelled, but I did have one that wasn't declared.  It was an input type that had its name set but not the ID
0
 
LVL 2

Author Closing Comment

by:Alemus
ID: 36524854
As I mentioned in my last comment, this wan't the actual solution, but it made me re-examine my form elements and find the one with the name declared but not the id.
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 36524859
Aa Hah! The old name/id switcheroo! I've done the same. Glad I could steer you in the right direction.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question