JavaScript运行时错误:无法获取属性';切片';指未定义的或空的引用

JavaScript运行时错误:无法获取属性';切片';指未定义的或空的引用,javascript,jquery,visual-studio-2013,Javascript,Jquery,Visual Studio 2013,我一直收到这个消息。当我在“经典”HTML页面中尝试时,效果很好。但当我在VS 2013中尝试时,我遇到了这个问题 第64行第9列未处理的异常(毫秒)-appx://eabd59c7-f115-49ff-9716-94243f12fc3b/js/Action.js 0x800a138f-JavaScript运行时错误:无法获取未定义或空引用的属性“slice” 这方面我是新手。有人能帮帮我吗?!代码如下: <!DOCTYPE html> <html> <head&g

我一直收到这个消息。当我在“经典”HTML页面中尝试时,效果很好。但当我在VS 2013中尝试时,我遇到了这个问题

第64行第9列未处理的异常(毫秒)-appx://eabd59c7-f115-49ff-9716-94243f12fc3b/js/Action.js 0x800a138f-JavaScript运行时错误:无法获取未定义或空引用的属性“slice”

这方面我是新手。有人能帮帮我吗?!代码如下:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Sage_Cell_Server</title>

    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.2.0/js/base.js"></script>
    <script src="//Microsoft.WinJS.2.0/js/ui.js"></script>

    <!-- Sage_Cell_Server references -->
    <link href="/css/default.css" rel="stylesheet" />
    <script src="/js/default.js"></script>
    <script src="/js/jquery-2.1.1.min.js"></script>
    <script src="/js/Action.js"></script>


    <script>

        $(function () {
            // Make *any* div with class 'compute' a Sage cell
            sagecell.makeSagecell({
                inputLocation: 'div.compute',
                template: sagecell.templates.minimal,
                evalButtonText: 'Evaluate'
            });

    // Make the div with id 'mycell' a Sage cell
    sagecell.makeSagecell({
        inputLocation: '#mycell',
        template: sagecell.templates.minimal,
        evalButtonText: 'Activate'

    });
});
    </script>



</head>
<body>
    <h1>Embedded Sage Cells</h1>

    <h2>Factorial</h2>
    Click the “Activate” button below to calculate factorials.
    <div id="mycell">
        <script type="text/x-sage">
            @interact
            def _(a=(1, 10)):
            print factorial(a)
        </script>
    </div>

    <h2>Your own computations</h2>
    Type your own Sage computation below and click “Evaluate”.
    <div class="compute">
    <script type="text/x-sage">
        plot(sin(x), (x, 0, 2*pi))
    </script></div>
    <div class="compute">
        <script type="text/x-sage">
            @interact
            def f(n=(0,10)):
            print 2^n
        </script>
    </div>
</body>
</html>

Sage_Cell_服务器
$(函数(){
//将类为“compute”的*any*div设为Sage单元格
sagecell.makeSagecell({
inputLocation:'div.compute',
模板:sagecell.templates.minimal,
evalButtonText:“评估”
});
//将id为“mycell”的div设置为Sage单元格
sagecell.makeSagecell({
输入位置:“#mycell”,
模板:sagecell.templates.minimal,
evalButtonText:“激活”
});
});
嵌埋鼠尾草细胞
阶乘的
单击下面的“激活”按钮计算阶乘。
@互动
定义(a=(1,10):
印刷阶乘(a)
你自己的计算
在下面键入您自己的Sage计算,然后单击“评估”。
绘图(sin(x)、(x,0,2*pi))
@互动
def(n=(0,10)):
打印2^n
Action.js--->问题出在这里

var _gaq = _gaq || [];
_gaq.push(['sagecell._setAccount', 'UA-29124745-1']);
_gaq.push(['sagecell._setDomainName', 'sagemath.org']);
_gaq.push(['sagecell._trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

(function() {
"use strict";
var undefined;

// Make a global sagecell namespace for our functions
window.sagecell = window.sagecell || {};

if (!document.head) {
    document.head = document.getElementsByTagName("head")[0];
}

var $ = jQuery.noConflict(true);
if (jQuery === undefined) {
    window.$ = jQuery = $;
}
sagecell.jQuery = $;

sagecell.URLs = {};

(function () {
    /* Read the Sage Cell server's  root url from one of the following locations:
         1. the variable sagecell.root
         2. a tag of the form <link property="sagecell-root" href="...">
         3. the root of the URL of the executing script */
    var el;
    if (sagecell.root) {
        sagecell.URLs.root = sagecell.root;
    } else if ((el = $("link[property=sagecell-root]")).length > 0) {
        sagecell.URLs.root = el.last().attr("href");
    } else {
        /* get the first part of the last script element's src that loaded something called 'embedded_sagecell.js'
           also, strip off the static/ part of the url if the src looked like 'static/embedded_sagecell.js'
           modified from MathJax source
           We could use the jquery reverse plugin at  http://www.mail-archive.com/discuss@jquery.com/msg04272.html 
           and the jquery .each() to get this as well, but this approach avoids creating a reversed list, etc. */
        var scripts = (document.documentElement || document).getElementsByTagName("script");
        var namePattern = /^.*?(?=(?:static\/)?embedded_sagecell.js)/;
        for (var i = scripts.length-1; i >= 0; i--) {
            var m = (scripts[i].src||"").match(namePattern);
            if (m) {
                var r = m[0];
                break;
            }
        }
        if (r === "" || r === "/") {
            r = window.location.protocol + "//" + window.location.host + "/";
        }
        sagecell.URLs.root = r;
    }
    if (sagecell.URLs.root.slice(-1) !== "/") {
        sagecell.URLs.root += "/";
    }
}());

...
var _gaq=_gaq | |[];
_gaq.push(['sagecell._setAccount','UA-29124745-1']);
_gaq.push(['sagecell._setDomainName','sagemath.org']);
_gaq.push(['sagecell._trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://ssl' : 'http://www“)+”.google analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();
(功能(){
“严格使用”;
var未定义;
//为我们的函数创建一个全局sagecell命名空间
window.sagecell=window.sagecell | |{};
如果(!document.head){
document.head=document.getElementsByTagName(“head”)[0];
}
var$=jQuery.noConflict(true);
if(jQuery==未定义){
窗口。$=jQuery=$;
}
sagecell.jQuery=$;
sagecell.url={};
(功能(){
/*从以下位置之一读取Sage Cell服务器的根url:
1.变量sagecell.root
2.表格的标签
3.执行脚本的URL的根*/
var-el;
if(sagecell.root){
sagecell.url.root=sagecell.root;
}else if((el=$(“链接[property=sagecell根]))。长度>0){
sagecell.url.root=el.last().attr(“href”);
}否则{
/*获取最后一个脚本元素的src的第一部分,它加载了一个名为“embedded_sagecell.js”的东西
另外,如果src看起来像“static/embedded_sagecell.js”,则去掉url的static/part
从MathJax源代码修改
我们可以在以下位置使用jquery反向插件:http://www.mail-archive.com/discuss@jquery.com/msg04272.html
和jquery.each()也可以得到这个结果,但这种方法避免了创建反向列表等*/
var scripts=(document.documentElement | | document).getElementsByTagName(“脚本”);
var namePattern=/^.*(?=(?:static\/)?embedded_sagecell.js)/;
对于(var i=scripts.length-1;i>=0;i--){
var m=(scripts[i].src | |“”).match(namePattern);
如果(m){
var r=m[0];
打破
}
}
如果(r==”| r==“/”){
r=window.location.protocol+“/”+window.location.host+“/”;
}
sagecell.url.root=r;
}
if(sagecell.url.root.slice(-1)!=“/”){
sagecell.url.root+=“/”;
}
}());
...

或者当我删除该行时,我在ms中第64行第9列收到未处理的异常消息-appx://eabd59c7-f115-49ff-9716-94243f12fc3b/js/Action.js 0x800a138f-JavaScript运行时错误:无法获取未定义或空引用的属性“slice”,我认为问题出在该脚本中(调试程序直到最后都无法读取)这个问题已经解决了:D但是现在我在ms中第64行第9列有一个未处理的错误异常-appx://eabd59c7-f115-49ff-9716-94243f12fc3b/js/Action.js 0x800a138f-JavaScript运行时错误:无法获取未定义或空引用的属性“slice”(其位于嵌入的单元格脚本中)我猜Action.js脚本没有加载到页面上。运行一些测试以确保加载。相对路径可能不正确,也可以尝试将type=“Text/Javascript”添加到脚本标记中。该脚本sagecell.sagemath.org/static/embedded_sagecell.js“>未正确加载它不断向我发送此错误,可能我需要涉及一些库或其他内容…脚本正确,因为它在网页(HTML文档)中工作