Blynn
Blynn

Reputation: 1421

Chrome packaged apps local root html links via Sandbox Manifest 2

I'm getting a red error when I click on any local url inside the app it says.

Can't open same-window link to "chrome-extension://nmajpganl/options.html"; try target="_blank". index.html:1

Is there a way to link locally with permissions? Or do I have to rewrite everything to be on one page?

I think this is related to the Chrome Manifest Sandbox .. needing to include all the pages you will link to? Can anyone confirm this?

Upvotes: 3

Views: 2772

Answers (4)

Joshua Smith
Joshua Smith

Reputation: 3809

The right answer is here, but it seems to have been dismissed, so let me expand on it. iframe's are not allowed to visit other sites, but you can use one a wrapper around all your local stuff. Something like this:

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, user-scalable=no, maximum-scale=1, minimum-scale=1" />
    <style>
html, body, iframe {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  border: none;
  overflow: hidden;
}
    </style>
  </head>
  <body><iframe src="index.html"></iframe></body>
</html>

Those meta tags probably aren't needed, but I use them everywhere.

This seems to solve the problem of navigation within a multi-html-page local app.

Upvotes: 1

Anonymous Coward
Anonymous Coward

Reputation: 11

You can use an <iframe> inside your main.html.

Upvotes: 0

Dipesh
Dipesh

Reputation: 379

The New Chrome Packaged Apps do not support navigation. You can either create new window or replace the content in body or use webview tag of the app.

Upvotes: 0

sowbug
sowbug

Reputation: 4672

Packaged apps aren't websites. A principal difference between apps and websites is there's no navigation. You have a few options:

  1. Create a window for your options the same way you did for your main window.

  2. As you say, rewrite the app to manipulate the main window's DOM rather than "replacing the DOM with that of a new location" (a fancy way to say navigation).

  3. Use <webview>. It's very unlikely (assuming options means something like a prefs page) that this is what you want. But you could do it.

  4. As the error message says, use target=_blank and figure out a way for a normal Chrome tab to open it (e.g., host it on a website). For your application, this approach would be insanity.

Upvotes: 3

Related Questions