blockRemotePages Method

Use this method to block remote pages, and also set up a white list of allowable remote pages.

intel.xdk.device.blockRemotePages(shouldblock,whitelist);

Description:

Use this method to block remote pages from this application, while turning on the ability to intercept a remote page redirect.

This method requires two parameters, a boolean value that indicates whether to block remote pages or not, and a pipe ("|") delimited list of domains or domain:port pairs that are not to be blocked if the boolean value is "true".

Following a call to this method, it will fire the intel.xdk.device.remote.block event which includes a "success" property that is set to true or false and a "blocked" property which contains the URL which was blocked. The application can ignore this URL or use the device.showRemoteSite method to view it instead.

Platforms:

Parameters:

  • shouldblock: This boolean value controls whether the application should block remote pages or not.
  • whitelist: This parameter is a "|" delimited list of of domains and or domain:port combos that are NOT to be blocked if shouldblock=true.

Events:

  • intel.xdk.device.remote.block: This event will fire once the command has made a round trip to the server. Its event object includes a "success" property that is set to true or false and an "blocked" property which contains the URL which was blocked.

Example:

 
//Set up a list of domains for which you allow remote pages
var whitelist = "www.cnn.com|www.intel.xdk.com:44|www.aol.com";

//Set up a list of domains for which you allow remote pages
intel.xdk.device.blockRemotePages(true,whitelist);

document.addEventListener("intel.xdk.device.remote.block",blockRemotePagesEvent,false);
var blockRemotePagesEvent=function(event)
{
        if(event.success==false)
           {
              alert("error: " + event.message);
           }
        else
           {
              alert(event.blocked + "ignored");
           }
}
            
For more complete information about compiler optimizations, see our Optimization Notice.