my mapserver does not work in IE

Björn Platzen bjoern.platzen at MOMATEC.DE
Thu Dec 9 10:46:13 EST 2004


Hi Ahmet,

this one works for me in all browsers:

function startRubber (evt) {
    if (document.mapform.mode.value=='zoombox'){
        if (document.all) {
            var r = document.all.rubberBand;
            r.style.width = 0;
            r.style.height = 0;
            r.style.pixelLeft = event.x;
            r.style.pixelTop  = event.y;
            r.style.visibility = 'visible';
            document.mapform.boxxy1.value = event.offsetX + ' ' +
event.offsetY;
        }
        else if (document.getElementById) {
            var r = document.getElementById('rubberBand');
            r.style.width = 0;
            r.style.height = 0;
            r.style.left = evt.clientX + 'px';
            r.style.top = evt.clientY + 'px';
            r.style.visibility = 'visible';
            document.mapform.boxxy1.value = evt.clientX + ' ' +
evt.clientY;
        }
        else if (document.layers) {
            var r = document.rubberBand;
            r.clip.width = 0; r.clip.height = 0;
            r.left = evt.x;
            r.top = evt.y;
            r.visibility = 'show';
            document.mapform.boxxy1.value = evt.x + ' ' + evt.y;
        }
        if (document.layers)
            document.captureEvents(Event.MOUSEMOVE);
            document.onmousemove = moveRubber;

    }
}

function moveRubber (evt) {
    if (document.all) {
        var r = document.all.rubberBand;
        r.style.width = event.x - r.style.pixelLeft;
        r.style.height = event.y - r.style.pixelTop;
    }
    else if (document.getElementById) {
        var r = document.getElementById('rubberBand');
        r.style.width = evt.clientX - parseInt(r.style.left);
        r.style.height = evt.clientY - parseInt(r.style.top);
    }
    else if (document.layers) {
        var r = document.rubberBand;
        r.clip.width = evt.x - r.left;
        r.clip.height = evt.y - r.top;
        r.document.open();
        r.document.write('<TABLE WIDTH="' + r.clip.width + '" HEIGHT="'
+ r.clip.height + '" BORDER="1"><TR><TD><\/TD><\/TR><\/TABLE>');
        r.document.close();
    }
}

function stopRubber (evt) {
        if (document.all){
        document.mapform.boxxy2.value = event.offsetX + ' ' +
event.offsetY;
        }
    if (document.all && !document.getElementById){
        document.releaseEvents(Event.MOUSEMOVE);
        document.onmousemove = null;
                r.style.visibility = 'hidden';

        document.mapform.submit();
        }
        else if (document.getElementById) {
        var r = document.getElementById('rubberBand');
                document.onmousemove = null;
                if (!document.all){
                document.mapform.boxxy2.value = evt.clientX + ' ' +
evt.clientY;
                }
                if (document.mapform.boxxy2.value ==
document.mapform.boxxy1.value){
            document.mapform.imgxy.value=document.mapform.boxxy1.value;
            document.mapform.boxxy1.value='';
            document.mapform.boxxy2.value='';
                        document.mapform.mode.value="pan";
                    document.mapform.zoomdir.value = 2;
                }
                document.mapform.submit();

        }
        else if (document.layers) {
        var r = document.rubberBand;
        document.mapform.boxxy2.value = evt.x + ' ' + evt.y;
                document.mapform.submit();
        }

}


I'm setting the mode in my "mapform" and submit a hidden input for
MouseDown and MouseUp (boxxy1 and boxxy2). If boxxy1==boxxy2, I delete
the values and fill imgxy instead and set a zoomfactor = 2.

I don't know if that will work for you as well, but here it's tested
with IE6, Firefox 0.8-1.0, Netscape 7, Mozilla 1.7 and Safari.

hth,

regards,

Bjoern.



More information about the mapserver-users mailing list