Solved

Google Javascript issues in Explorer 8 and Firefox

Posted on 2011-09-09
13
346 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
  • 7
  • 6
13 Comments
 
LVL 21

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 21

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
 
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 21

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 21

Expert Comment

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

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 21

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 21

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now