如何在同一页面而不是弹出窗口中打开Chrome应用程序? [英] How to open chrome app in same page rather than popup window?
问题描述
我正在尝试从串行设备arduino(串行监视器)读取数据.但是我不希望应用程序在新窗口中打开.它应该在Chrome标签中打开.
I am trying to read data from serial device arduino (serial monitor). But I dont want app to open in new window. It should open in chrome tab.
//manifest.json
{
"manifest_version": 2,
"name": "Serial Monitor",
"description": "Monitors your serial port and allows you to read and write to it like you could with Arduino's IDE.",
"version": "1.0.4",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": {
"16": "extentionAssets/icon-16x16.jpeg",
"128": "extentionAssets/icon-128x128.jpeg"
},
"permissions": [
"tabs","serial"
]
}
//background.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('demo.html', {
bounds: {
width: 1160,
height: 960,
left: 100,
top: 100
},
minWidth: 1160,
minHeight: 960
});
});
chrome.runtime.onSuspend.addListener(function() {
// Do some simple clean-up tasks.
});
chrome.runtime.onInstalled.addListener(function() {
// chrome.storage.local.set(object items, function callback);
});
我还使用了chrome.create.tabs
函数,但是它没有帮助.新的标签页会立即打开和关闭.
I also used chrome.create.tabs
function, but it is not helping.. new tab opens and closes immediately.
推荐答案
似乎您将chrome扩展名与chrome应用程序混淆了.
It seems that you are confusing chrome extensions with chrome apps.
您无法尝试在chrome打包的应用程序中执行任何操作,清单文件似乎是CPA而不是扩展程序所需的文件.甚至更多,您正在使用background.js脚本,该脚本将打开一个新的chrome应用程序窗口,其中包含demo.html页面.
What you are trying to do is not possible in a chrome packaged app, your manifest file seems to be the one you need for a CPA not for an extension. Even more, you are using a background.js script that will open a new chrome app window with the demo.html page in it.
如果您指的是chrome扩展程序,则可能需要将问题标记为 google-chrome-extension .
If you are refering to a chrome extension then you might want to tag your question as google-chrome-extension.
如果没有,那么答案很简单:无法在chrome打包的应用中打开标签页,chrome浏览器标签页的概念不适用.
If not, then the answer is easy: It is not possible to open tabs in chrome packaged apps, the concept of a chrome browser tab doesn't apply.
这篇关于如何在同一页面而不是弹出窗口中打开Chrome应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!