chrome.app.window.create 创建两个 windows
chrome.app.window.create creates two windows
在深入研究如何在 Chrome 应用程序中打开多个 HTML 文件后,我找到了 this 作为解决方案。此解决方案打开一个新的 window 而不是在一个 window.
中
但出于某种原因,当我按下按钮超链接时,它会同时打开两个 windows 。而且我不知道这在代码中的哪个位置导致了问题。
所以这是软件的重要部分:(script.js)
document.querySelector('#startButton').addEventListener('click', function () {
chrome.app.window.create('index.html', { "width": 400, "height": 500 });
window.close();
});
这是按钮:
<button onclick="window.location.href='index.html'" id="startButton">Let's Go!</button>
window.close()只是关闭了前面的window,所以跟那个没有关系。
我的 Git 存储库将为您提供我未提供的内容(在 MineKart_desktop 文件夹下):https://github.com/Mr-El/MineKart
在你的按钮上,你有两个触发函数:
onclick 属性打开 window 'index.html'
创建新的事件监听器window'index.html'
从按钮中删除 onclick 属性,看看会发生什么!
在深入研究如何在 Chrome 应用程序中打开多个 HTML 文件后,我找到了 this 作为解决方案。此解决方案打开一个新的 window 而不是在一个 window.
中但出于某种原因,当我按下按钮超链接时,它会同时打开两个 windows 。而且我不知道这在代码中的哪个位置导致了问题。
所以这是软件的重要部分:(script.js)
document.querySelector('#startButton').addEventListener('click', function () {
chrome.app.window.create('index.html', { "width": 400, "height": 500 });
window.close();
});
这是按钮:
<button onclick="window.location.href='index.html'" id="startButton">Let's Go!</button>
window.close()只是关闭了前面的window,所以跟那个没有关系。
我的 Git 存储库将为您提供我未提供的内容(在 MineKart_desktop 文件夹下):https://github.com/Mr-El/MineKart
在你的按钮上,你有两个触发函数:
onclick 属性打开 window 'index.html'
创建新的事件监听器window'index.html'
从按钮中删除 onclick 属性,看看会发生什么!