urls

The urls plugin exposes the open method, which allows opening external URLs.
It’ll save you the trouble of dealing with edge cases where window.open() will not work (embedded iframe, facebook browser, mobile application).

Example

// Open some external URL in another tab when user clicks button
myButton.addEventListener('click', function() {
    player.urls.open('https://helloeko.com');
});

Init Options

options : object

Initialization options for the urls plugin.

options.target : number
property

The default target to use as the 2nd argument to the window.open() method.

Default: _blank
Example

// playerOptions.json
{
    "plugins": {
        "urls": {
            "target": "_self"
        }
    }
}

// app.js
// URL will be opened with target '_blank' by default (when 2nd argument is omitted)
player.urls.open('https://helloeko.com');

Properties

player.urls.version : string
propertyreadonly

The urls plugin’s version string.

Example

console.log('The urls plugin version is', player.urls.version);

Methods

player.urls.open(url, [target]) ⇒ boolean
method

Open/load a page with the given url.
The urls.open event will be triggered.

Returns: boolean - Whether the operation was successful or not.

Param Type Description
url string The url of the page to open.
[target] string Optional. Target attribute, the 2nd argument of the window.open() method. By default the target will be _blank (which means it will open a new tab).

Example

player.on('urls.open', function(url, success) {
      if (success) {
         console.log('Successfully opened:', url);
      } else {
         console.log('Failed to open:', url);
      }
});

player.urls.open('https://helloeko.com');

Events

“urls.open”
event

Triggered when open is executed.

Param Type Description
url string The url that was opened.
success boolean Whether the operation was successful or not.

Example

player.on('urls.open', function(url, success) {
      if (success) {
         console.log('Successfully opened:', url);
      } else {
         console.log('Failed to open:', url);
      }
});

player.urls.open('https://helloeko.com');

“urls.openinparent”
event

Triggered when the urls plugin delegates the opening of the URL to other entities listening to the player.

Param Type Description
data object Data about the url to be opened.
data.url string The url to be opened.
data.target string The target of the url to be opened.

Example

player.on('urls.openinparent', function(data) {
    window.open(data.url, data.target);
}
Rate this page: X
Tell us more!