语言

Menu
Sites
Language
Open external link in browser

Hi.

We build Hosted Web App, it's app for social network and have many external links in user posts.

As well, links between pages inside our App use some different subdomains and one external site for counting statistics with back-redirect into our App..

We wanna open all user external links in browser, but "our external" links in App.

List of domains for example:

  • http://main.com
  • https://auth.main.com
  • http://video.main.com
  • http://stat.com/counter123/back/redirect/url

I try to use code like this:

$(window).on("click", "a", function (e) {
    var rbPattern,
        appControl;

    // Pattern for statistik link with back-redir
    rbPattern = new RegExp("^http://stat.com/[a-z]+[0-9]+/domain.com");

    if (e.target.host !== 'domain.com' && !rbPattern.test(e.target.href)) {
        try {
            appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/view", e.target.href);
            tizen.application.launchAppControl(
                appControl,
                null,
                function () {
                    console.log("Browser opened");
                },
                function (e) {
                    App.Share.notify("Browser error: " + e.message);
                }
            );
        } catch (e) {
            alert(e.name + ': ' + e.message);
        }
        e.stopPropagation();
        e.preventDefault();
    }
});

But catch error "ReferenceError: Can't find variable: tizen".

响应

8 回复
Alex Dem

Hi,
I think you could create "Tizen Web UI Framework" project.
tizen-web-ui-fw-libs.js & tizen-web-ui-fw.js should be included in all tizen web framework related files.
Or (possibly) you perform your javascript code before Tizen Framework files were loaded.
Alexey.

Vasiliy Lazarev

I think "Tizen Web UI Framework" - not my way, because in config.xml:

<tizen:content src="http:/main.com">

I call tizen-object after click by link - of course, this event fired after load all scripts on page.

Alex Dem

Hi,
If your app is not located on Tizen device filesystem I think there is no way to get access to 'tizen' object from remote page.
Alexey.

AVSukhov

Hello,

You are using hosted app, these applications reside on the server and they do not have access to "tizen" object. Accordingly you can not use Device API.

Vasiliy Lazarev

Maybe you know how could I configure the config.xml to open "not my" externel link in browser? 

AVSukhov

Hello,

You may try to determinete the correct links in "access" tag, i.e. links matching "access origin" value will open in your application, the rest in browser.

<access origin="your link" subdomains="true" />

AVSukhov

Hello,

You may try to determinete the correct links in "access" tag, i.e. links matching "access origin" value will open in your application, the rest in browser.

<access origin="your link" subdomains="true" />

Alex Dem

Hi,
I am not sure that it is possible,
Maybe you could create Native app based on WebView to control all transitions between pages.
Alexey.