Hi,
I am not very experienced with javascript at all, but i need to modify a website that contains javascript. I am using a program that uses the mouseover function to show the latitude and longitude of an area when the user scrolls over a picture of a map. This program works fine in internet explorer, but does not work with netscape7 or firefox. I have no idea how to go about making it work for these browsers. Here is the script to the mouseover. Any help would be appreciated! THANK YOU!
function Is() {
var agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
this.ns2 = (this.ns && (this.major == 2));
this.ns3 = (this.ns && (this.major == 3));
this.ns4b = (this.ns && (this.minor < 4.04));
this.ns4 = (this.ns && (this.major >= 4));
this.ie = (agent.indexOf("msie")!= -1);
this.ie3 = (this.ie && (this.major == 2));
this.ie4 = (this.ie && (this.major >= 4));
this.op3 = (agent.indexOf("opera")!= -1);
this.win = (agent.indexOf("win")!=-1);
this.mac = (agent.indexOf("mac")!=-1);
this.unix = (agent.indexOf("x11")!=-1);
}
var is = new Is();
if(is.ns4) {
doc = "document";
sty = "";
htm = ".document"
} else if(is.ie4) {
doc = "document.all";
sty = ".style";
htm = ""
}
redVal = 0;
grnVal = 0;
bluVal = 0;
zoomVal = 9;
sizeVal = 9;
function SubmitForm() {
//if (redVal > 0) { redVal++; if (redVal == 6) { redVal++; }}
//else { redVal = document.forms[1].elements["lastred"].value; }
//if (grnVal > 0) { grnVal++; if (grnVal == 6) { grnVal++; }}
//else { grnVal = document.forms[1].elements["lastgrn"].value; }
//if (bluVal > 0) { bluVal++; if (bluVal == 6) { bluVal++; }}
//else { bluVal = document.forms[1].elements["lastblu"].value; }
//if (zoomVal == 9) { zoomVal = document.forms[1].elements["lastlevel"].value; }
//if (sizeVal == 9) { sizeVal = document.forms[1].elements["lastsize"].value; }
//document.forms[1].elements["imagex"].value = xVal;
//document.forms[1].elements["imagey"].value = yVal;
document.forms[1].elements["imagex"].value = nowX;
document.forms[1].elements["imagey"].value = nowY;
//document.forms[1].elements["red"].value = redVal;
//document.forms[1].elements["grn"].value = grnVal;
//document.forms[1].elements["blu"].value = bluVal;
//document.forms[1].elements["level"].value = zoomVal;
//document.forms[1].elements["size"].value = sizeVal;
document.forms[1].submit();
}
function DoHocusPocus() {
deltaXgeo = Math.abs(lowerRightXgeo - upperLeftXgeo);
deltaYgeo = Math.abs(lowerRightYgeo - upperLeftYgeo);
pctX = nowX / ImgX;
pctY = nowY / ImgY;
offsetXgeo = deltaXgeo * pctX;
offsetYgeo = deltaYgeo * pctY;
NewXgeo = upperLeftXgeo + offsetXgeo;
NewYgeo = upperLeftYgeo - offsetYgeo;
NewXshortgeo = ( Math.round( NewXgeo * 1000000)) / 1000000;
NewYshortgeo = ( Math.round( NewYgeo * 1000000)) / 1000000;
document.forms[0].elements[1].value = NewXshortgeo;
document.forms[0].elements[0].value = NewYshortgeo;
deltaXutm = Math.abs(lowerRightXutm - upperLeftXutm);
deltaYutm = Math.abs(lowerRightYutm - upperLeftYutm);
offsetXutm = deltaXutm * pctX;
offsetYutm = deltaYutm * pctY;
NewXutm = upperLeftXutm + offsetXutm;
NewYutm = upperLeftYutm - offsetYutm;
NewXshortutm = Math.round( NewXutm );
NewYshortutm = Math.round( NewYutm );
document.forms[0].elements[3].value = NewXshortutm;
document.forms[0].elements[2].value = NewYshortutm;
}
function DispCoords(eventType) {
if(is.ns4) {
ImgLayer = document.layers.ImgLayer;
xVal = eventType.layerX;
yVal = eventType.layerY;
ImgX = ImgLayer.clip.width;
ImgY = ImgLayer.clip.height;
xClick = eventType.layerX;
yClick = eventType.layerY;
} else {
xVal = parseInt(window.event.x);
yVal = parseInt(window.event.y);
layerArray = document.all.item("ImgLayer");
imgLayer = document.all.item("ImgLayer").style;
ImgX = document.images[0].width;
ImgY = document.images[0].height;
//xClick = evtObj.layerX;
//yClick = evtObj.layerY;
}
with (document.forms[0]) {
if(is.ns4) {
if (( eventType.pageX > ImgLayer.pageX) && (eventType.pageY > ImgLayer.pageY)) {
if (xVal <= ImgX && yVal <= ImgY) {
nowX = xVal;
nowY = yVal;
DoHocusPocus();
}
}
} else if(is.ie4 ¦¦ is.ie5) {
if ( xVal > parseInt(imgLayer.left) && yVal > parseInt(imgLayer.top) ) {
if ( xVal <= (parseInt(imgLayer.left) + ImgX) && yVal <= (parseInt(imgLayer.top) + ImgY)) {
nowX = xVal - parseInt(imgLayer.left);
nowY = yVal - parseInt(imgLayer.top);
DoHocusPocus();
}
}
}
}
}
function DoIt() {
upperLeftXgeo = arguments[0];
upperLeftYgeo = arguments[1];
lowerRightXgeo = arguments[2];
lowerRightYgeo = arguments[3];
upperLeftXutm = arguments[4];
upperLeftYutm = arguments[5];
lowerRightXutm = arguments[6];
lowerRightYutm = arguments[7];
if(is.ns4) {
window.captureEvents(Event.MOUSEMOVE);
window.onMouseMove = DispCoords;
}
else if((is.ie4) ¦¦ (is.ie5)) {
document.onmousemove = DispCoords;
}
}
I am not very experienced with javascript at all, but i need to modify a website that contains javascript. I am using a program that uses the mouseover function to show the latitude and longitude of an area when the user scrolls over a picture of a map. This program works fine in internet explorer, but does not work with netscape7 or firefox. I have no idea how to go about making it work for these browsers. Here is the script to the mouseover. Any help would be appreciated! THANK YOU!
function Is() {
var agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
this.ns2 = (this.ns && (this.major == 2));
this.ns3 = (this.ns && (this.major == 3));
this.ns4b = (this.ns && (this.minor < 4.04));
this.ns4 = (this.ns && (this.major >= 4));
this.ie = (agent.indexOf("msie")!= -1);
this.ie3 = (this.ie && (this.major == 2));
this.ie4 = (this.ie && (this.major >= 4));
this.op3 = (agent.indexOf("opera")!= -1);
this.win = (agent.indexOf("win")!=-1);
this.mac = (agent.indexOf("mac")!=-1);
this.unix = (agent.indexOf("x11")!=-1);
}
var is = new Is();
if(is.ns4) {
doc = "document";
sty = "";
htm = ".document"
} else if(is.ie4) {
doc = "document.all";
sty = ".style";
htm = ""
}
redVal = 0;
grnVal = 0;
bluVal = 0;
zoomVal = 9;
sizeVal = 9;
function SubmitForm() {
//if (redVal > 0) { redVal++; if (redVal == 6) { redVal++; }}
//else { redVal = document.forms[1].elements["lastred"].value; }
//if (grnVal > 0) { grnVal++; if (grnVal == 6) { grnVal++; }}
//else { grnVal = document.forms[1].elements["lastgrn"].value; }
//if (bluVal > 0) { bluVal++; if (bluVal == 6) { bluVal++; }}
//else { bluVal = document.forms[1].elements["lastblu"].value; }
//if (zoomVal == 9) { zoomVal = document.forms[1].elements["lastlevel"].value; }
//if (sizeVal == 9) { sizeVal = document.forms[1].elements["lastsize"].value; }
//document.forms[1].elements["imagex"].value = xVal;
//document.forms[1].elements["imagey"].value = yVal;
document.forms[1].elements["imagex"].value = nowX;
document.forms[1].elements["imagey"].value = nowY;
//document.forms[1].elements["red"].value = redVal;
//document.forms[1].elements["grn"].value = grnVal;
//document.forms[1].elements["blu"].value = bluVal;
//document.forms[1].elements["level"].value = zoomVal;
//document.forms[1].elements["size"].value = sizeVal;
document.forms[1].submit();
}
function DoHocusPocus() {
deltaXgeo = Math.abs(lowerRightXgeo - upperLeftXgeo);
deltaYgeo = Math.abs(lowerRightYgeo - upperLeftYgeo);
pctX = nowX / ImgX;
pctY = nowY / ImgY;
offsetXgeo = deltaXgeo * pctX;
offsetYgeo = deltaYgeo * pctY;
NewXgeo = upperLeftXgeo + offsetXgeo;
NewYgeo = upperLeftYgeo - offsetYgeo;
NewXshortgeo = ( Math.round( NewXgeo * 1000000)) / 1000000;
NewYshortgeo = ( Math.round( NewYgeo * 1000000)) / 1000000;
document.forms[0].elements[1].value = NewXshortgeo;
document.forms[0].elements[0].value = NewYshortgeo;
deltaXutm = Math.abs(lowerRightXutm - upperLeftXutm);
deltaYutm = Math.abs(lowerRightYutm - upperLeftYutm);
offsetXutm = deltaXutm * pctX;
offsetYutm = deltaYutm * pctY;
NewXutm = upperLeftXutm + offsetXutm;
NewYutm = upperLeftYutm - offsetYutm;
NewXshortutm = Math.round( NewXutm );
NewYshortutm = Math.round( NewYutm );
document.forms[0].elements[3].value = NewXshortutm;
document.forms[0].elements[2].value = NewYshortutm;
}
function DispCoords(eventType) {
if(is.ns4) {
ImgLayer = document.layers.ImgLayer;
xVal = eventType.layerX;
yVal = eventType.layerY;
ImgX = ImgLayer.clip.width;
ImgY = ImgLayer.clip.height;
xClick = eventType.layerX;
yClick = eventType.layerY;
} else {
xVal = parseInt(window.event.x);
yVal = parseInt(window.event.y);
layerArray = document.all.item("ImgLayer");
imgLayer = document.all.item("ImgLayer").style;
ImgX = document.images[0].width;
ImgY = document.images[0].height;
//xClick = evtObj.layerX;
//yClick = evtObj.layerY;
}
with (document.forms[0]) {
if(is.ns4) {
if (( eventType.pageX > ImgLayer.pageX) && (eventType.pageY > ImgLayer.pageY)) {
if (xVal <= ImgX && yVal <= ImgY) {
nowX = xVal;
nowY = yVal;
DoHocusPocus();
}
}
} else if(is.ie4 ¦¦ is.ie5) {
if ( xVal > parseInt(imgLayer.left) && yVal > parseInt(imgLayer.top) ) {
if ( xVal <= (parseInt(imgLayer.left) + ImgX) && yVal <= (parseInt(imgLayer.top) + ImgY)) {
nowX = xVal - parseInt(imgLayer.left);
nowY = yVal - parseInt(imgLayer.top);
DoHocusPocus();
}
}
}
}
}
function DoIt() {
upperLeftXgeo = arguments[0];
upperLeftYgeo = arguments[1];
lowerRightXgeo = arguments[2];
lowerRightYgeo = arguments[3];
upperLeftXutm = arguments[4];
upperLeftYutm = arguments[5];
lowerRightXutm = arguments[6];
lowerRightYutm = arguments[7];
if(is.ns4) {
window.captureEvents(Event.MOUSEMOVE);
window.onMouseMove = DispCoords;
}
else if((is.ie4) ¦¦ (is.ie5)) {
document.onmousemove = DispCoords;
}
}