在新窗口中打开Chrome(Chrome应用) [英] Open Chrome in a new window (Chrome app)

查看:115
本文介绍了在新窗口中打开Chrome(Chrome应用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个chrome应用程序,当我单击一个按钮时,它会打开一个新的chrome窗口,此刻它只会打开一个新标签页.

I'm trying to create a chrome app that when i click on a button, it opens a new chrome window, at the moment it just opens a new tab.

html:

<html>
<head>
<script src="jquery-3.1.1.min.js"></script>
<script src="script.js"></script>
</head>

<body>

<button>Test</button>

</body>
</html>

JS:

$(document).ready(function() {
  $("button").click(function() {
    window.open(
      "https://www.google.com",
      "_blank",
      "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400"
    );
  });
});

推荐答案

遗憾的是,我无法做到这一点.

Sadly, there's no way to do that that I know of.

在应用程序的上下文中使用 window.open 有点麻烦,但是会导致在用户的默认浏览器(不一定是Chrome)中打开URL.无法控制浏览器如何选择打开它.

Using window.open in an app's context is a bit of a hack, but results in the URL being open in the user's default browser (not necessarily Chrome). There's no control as to how the browser chooses to open it.

有一个专门针对"Chrome应用程序"创建的Chrome应用程序API, chrome.browser .但是,它仍然没有提供在新窗口中打开的选项.

There's a Chrome App specific API that was created specifically with "open a page in Chrome" in mind, chrome.browser. However, it still doesn't provide an option to open in a new window.

最接近的方法是创建自己的浏览器":其中包含< webview> 的应用程序窗口.然后,您可以完全控制演示文稿,但是它未与Chrome的配置文件集成,因此可能需要进行其他工作才能实现对话框和浏览器控件之类的内容.请参见浏览器示例应用 < webview> 文档.

The closest you can get is to create your own "browser": an app window with a <webview> in it. Then you have full control over presentation, but it's not integrated with Chrome's profile and may require additional work to implement things like dialogs and browser controls. See the Browser sample app and <webview> documentation.

这篇关于在新窗口中打开Chrome(Chrome应用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆