JavaScript Adobe AIR使用Sandbox Bridge打开新URL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript Adobe AIR使用Sandbox Bridge打开新URL相关的知识,希望对你有一定的参考价值。

//This code is placed in the root document header
//This function is written to run from the sandbox. It opens a url in an external browser
function openExternalURL(href) {
    var request = new air.URLRequest(href);
    try {            
        air.navigateToURL(request);
    }
    catch (e) {
        // handle error here
    }
}

//Create an object that will be used to expose AIR functionality to the browser sandbox
var Exposed = new Object();

//Exposed can now be read from the sandbox, so can the above function. The open url
//function is added as a method of the exposed object.
Exposed.openExternalURL = openExternalURL;

function doLoad() {
    //Place the Exposed object on the parentSandboxBridge property of the ui frame's window object.
    var frame = document.getElementById('UI').contentWindow.parentSandboxBridge = Exposed;
}
//doLoad is placed inline on the body tag.

//Now to run the external function from inside the sandbox use. The function expects
//an argument that contains a URL.
parentSandboxBridge.openExternalURL(href);

以上是关于JavaScript Adobe AIR使用Sandbox Bridge打开新URL的主要内容,如果未能解决你的问题,请参考以下文章