1

我在尝试在 Windows Phone IE11 Mobile 上测试的网站上遇到问题。基本上,在 Iphone、Android、Chrome、Firefox 甚至非 Windows 手机 IE11 上,此代码都可以正常工作,但在 IE11 Mobile 上,以下代码会提示“'App' is undefined”。

这是剃须刀cshtml:

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/bootstrap")
    @Scripts.Render("~/bundles/app")
    <script>
        $(document).ready(function () {
            try {
                var overlayUrl = "@Url.Content("~/Content/Images/front_license_outline.png")";
                var handleUrl = "@Url.Action("HandlePicture")";
                App.init(overlayUrl, handleUrl);
            } catch(ex) {alert(ex.message);}
        });
    </script>

这是在我测试过的所有其他浏览器上定义的 app.js 文件的精简版本。

var App = function() { 
    var init = function(overlayurl, hpu) {
        //My Code
    }

    return { init: init };
}();

我真的不知道会发生什么,我想帮助弄清楚如何为 WP EI11 Mobile 解决这个问题或解决这个问题的一些方法。

Jquery - 版本 1.10.2
Modernizer - 版本 2.6.2
Boostrap - 版本 3.3.6

如果您需要有关我的代码的更多信息,或者认为我可能没有包含解决此问题的重要内容,请告诉我,我将非常乐意提供。预先感谢您的帮助。

::EDIT::
我已经测试了编辑 App.init 函数中的每一行以及我可以在其他地方找到的许多无关的行并且问题仍然存在。

var App = function() { 
    var init = function() {
        //This is now literally no code here.
    }

    return { init: init };
}();

和剃刀 .cshtml 文件:

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/bootstrap")
    @Scripts.Render("~/bundles/app")
    <script>
        $(document).ready(function () {
            try { App.init(); } 
            catch(ex) { alert(ex.message); }
        });
    </script>

alert(ex.message) 仍然被触发。“应用程序”未定义。

4

2 回答 2

1

我现在已经摆脱了这个问题,并决定做一些我认为完全不相关的事情。找出引导网格系统无法正确显示的原因。当我这样做时,我偶然发现了一篇文章,建议我需要添加一个元标记:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

我的 .cshtml 文件头部的这个元标记解决了这个问题,原因我完全不知道。据我所知,这在其他浏览器中也没有任何副作用。使用此标记,app.js 文件可以在 IE11 Mobile 中正确加载。

目前,它解决了这个问题,但我计划确切地研究它在做什么。我希望这可以帮助任何处理类似问题的人。

于 2016-07-25T21:49:14.710 回答
0

通常有很多 Explorer 不能做的事情。检查您在代码中所做的事情是否可以在 IE 中执行。示例通常带有一个 if/else 语句,指定 IE 的代码和其他浏览器的代码。这是一个例子:

if (window.XMLHttpRequest) { // This would be the object you want to use
    // code for browser with x tool
    xmlhttp = new XMLHttpRequest();
 } else {
    // code for old IE browser without the tool
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
    // This would be the alternative in this browser
}

我不确定这是你要找的东西,但我希望它有所帮助。

于 2016-07-25T19:59:22.370 回答