Alemus
asked on
Google Javascript issues in Explorer 8 and Firefox
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.
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
}
ASKER
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.
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.
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?
Are you getting the alert to move the cursor to the desired location?
ASKER
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
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(.
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
Is line 254 one of the line is the above code? Check your spelling in the the getElementById arguments. IDs are case-sensitive.
ASKER
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.
Do you have two elements with the same ID?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The ID is "AddButtons".
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?
ASKER
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
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
ASKER
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.
Aa Hah! The old name/id switcheroo! I've done the same. Glad I could steer you in the right direction.
Can you post a link to a page where this code is being used?