IE浏览器检测后不会继续服务器响应,为什么?

时间:2013-10-01 20:17:10

标签: javascript asp.net cross-browser event-listener browser-detection

我正在创建一个跟踪工具,可以将按钮单击从任何域记录到数据库中。

我想使用Web Workers,但支持此功能的浏览器列表限制了......我添加了浏览器检测功能,将它们发送到正确的路径。

我的问题是,一旦我将浏览器检测添加到IE,我就不再获得服务器响应,(发布,重定向,没有)我做错了什么?

这是检测按钮的地方

            if ((isIE) && (isIE == true)) {

            function addBtnClickListener(e) {
                var btnClicked = this;

                var eventType = "button.click";
                var ctrBtnText = btnClicked.value;
                track(btnClicked, eventType, '', '', ctrBtnText, '', '', '', btnClicked);

                return false;
            }
        }
        else if ((isChrome) && (isChrome == true) || (isFirefox) && (isFirefox == true) || (isSafari) && (isSafari == true) || (isOpera) && (isOpera == true)) {
            //WEB WORKERS
            if (typeof SharedWorker != 'undefined') { //shared web worker is supported

                //Shared Worker
                function addBtnClickListener() {
                    var btnClicked = this;

                    var eventType = "button.click";
                    var ctrBtnText = btnClicked.value;
                    track(btnClicked, eventType, '', '', ctrBtnText, '', '', '', null, btnClicked);

                    return false;
                }
            }

            else if (typeof (Worker) != "undefined") { //web worker is supported

                //Web Worker
                function addBtnClickListener(e) {
                    e.preventDefault();
                    var btnClicked = this;

                    var eventType = "button.click";
                    var ctrBtnText = btnClicked.value;
                    track(btnClicked, eventType, '', '', ctrBtnText, '', '', '', btnClicked, null);
                    //this.click();
                    return true;
                }
            }

            else {
                //function addBtnClickListener(e) {
                var btnClicked = this;

                var eventType = "button.click";
                var ctrBtnText = btnClicked.value;
                track(btnClicked, eventType, '', '', ctrBtnText, '', '', '', btnClicked);

                return false;
                //}
            }
        }
        else { }

这是他们被记录的地方

        if ((isIE) && (isIE == true)) {

            console.log("IE");

            doRequestMethod(url);

            function GetXmlHttpObject() {
                if (window.XMLHttpRequest) {
                    //for IE7+, Firefox, Chrome, Opera, Safari
                    return new XMLHttpRequest();
                }
                if (window.ActiveXObject) {
                    //for IE6, IE5
                    return new ActiveXObject("Microsoft.XMLHTTP");
                }
                return null;
            }

            function doRequestMethod(url) {
                var xmlhttp = GetXmlHttpObject();
                if (xmlhttp == null) {
                    console.log("Browser does not support HTTP Request");
                    return;
                }
                xmlhttp.open("POST", url, true);
                xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xmlhttp.send(url);
            }

        }
        else if ((isChrome) && (isChrome == true) || (isFirefox) && (isFirefox == true) || (isSafari) && (isSafari == true) || (isOpera) && (isOpera == true)) {

            //WORKS AS IT SHOULD

        }
        else { }

一旦我删除IE检测检测,表单在IE中正常工作,我做错了吗?

0 个答案:

没有答案