Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Chrome应用程序,javascript问题_Javascript_Google Chrome App - Fatal编程技术网

Chrome应用程序,javascript问题

Chrome应用程序,javascript问题,javascript,google-chrome-app,Javascript,Google Chrome App,在chrome应用程序中,我有一些js/files.js正在index.html和其他html中加载 我使用的是: "app": { "launch": { "local_path": "index.html", "width":800, "height":800 } }, 但它已被弃用,并将于本月从webstore chrome中删除 我已按照建议进行了更改,包括: "app": { "background": { "scrip

在chrome应用程序中,我有一些js/files.js正在index.html和其他html中加载

我使用的是:

 "app": {
    "launch": {
      "local_path": "index.html",
      "width":800,  
      "height":800

    }
  },
但它已被弃用,并将于本月从webstore chrome中删除

我已按照建议进行了更改,包括:

"app": { "background": { "scripts": ["main.js"] } },
它在这里调用index.html 当我做了这个更改后,javascript不再工作了。不知道发生了什么。 我尝试并阅读了chrome应用程序和javascript文件的各种问题,但无法运行以下简单功能:

 var index = {
 initialize: function () {        
    setTimeout(function () {
        var user = null; 
        if (user == null) {
            window.location.href = "login.html";
        } else {
            //do something more
        }
    }, 500);
}

};
index.initialize();
从这个js文件中,这个代码段中有一个不平衡的(额外的)
}

"app": { "background": { "scripts": ["main.js"] } } },

您无法再从应用程序页面操纵
窗口。位置


基本上,我们的想法是必须使用单页应用程序,或者作为一种解决方法,您可以根据需要使用
chrome.app.window
打开新窗口。

是的,这只是我粘贴在这里的代码中,我已经修复了错误,您的代码中有一个尾随逗号,
},500);}。是的,这是我粘贴得很快的代码,对不起,我也修复了。但正如我所说的,javascript正在发挥作用。我建议阅读和文档。谢谢,我已经阅读了它们,但没有发现太多,我仍然被卡住了。我猜正在加载javascript代码,因为在initialize:function(){}中我添加了例如:document.querySelector('#greeting')。innerText='你好,世界!是“+新日期();”,它正在显示,但是,setTimeout或window.location.href等功能出现了一些不起作用的情况,我想不出有什么可以超越,这是正确的。我想这也是唯一的问题,每个js都工作正常,你提到的都是正确的方法,因此,我正在操作使用一个index.html并重定向同一索引中的其他页面。如果登录,一个单独的弹出窗口——作为一种权宜之计,在您将其作为单个页面应用程序实现之前——将不会是一种奇怪的用户体验。