Rhys Edwards Rhys Edwards - 24 days ago 5
HTML Question

Open Chrome in a new window (Chrome app)

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"
);
});
});

Xan Xan
Answer

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

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.

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.


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.

Comments