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://eko.com');
});
Init Options
options : object
Initialization options for the urls plugin.
Properties
player.urls.version : string
The urls plugin’s version string.
Example
console.log('The urls plugin version is', player.urls.version);
Methods
player.urls.open(url) ⇒ boolean
Open/load a page with the given url.
The module:urls#event: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. // TODO: what the return value when event is sent |
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://eko.com');
Events
“urls.intent”
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. |
Example
player.on('urls.intent', function(data) {
window.open(data.url);
}