PageRenderTime 75ms CodeModel.GetById 33ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/docs/api/extensions-api-tab-title.html

https://github.com/richtr/operaextensions.js
HTML | 59 lines | 43 code | 16 blank | 0 comment | 0 complexity | cd1b486840bf1ee39568e661912058b2 MD5 | raw file
 1<!DOCTYPE html>
 2<html>
 3<head>
 4  <title>Opera Extensions API Documentation</title>
 5  <link rel='stylesheet' href='../resources/markdown8.css'/>
 6  <meta charset='utf-8'>
 7  <meta charset='utf-8'>
 8</head>
 9<body>
10
11<p><a href="../index.html">&laquo; Documentation Home</a></p>
12
13<h1>BrowserTab.title</h1>
14
15<p class="note">This documentation relates to Opera's now deprecated .oex Extension API framework for Opera versions &lt;= 12.15 and also provided by our <a href="http://github.com/operasoftware/oex2nex">OEX2NEX shim library</a>.<br/><br/>For the latest Opera Extensions API documentation for Opera versions &gt; 12.15 please consult <a href="http://dev.opera.com/addons/extensions/">the latest Opera Extensions API documentation online</a>.</p>
16
17<h2>Description:</h2>
18
19<p>The readonly <code>title</code> attribute exposes the title of the current document within the browser tab. On getting, the browser only returns the title if the tab is open, otherwise an empty string is returned.</p>
20
21<h2>Syntax:</h2>
22
23<p><code>readonly string title // maps to document.title</code></p>
24
25<h2>Example:</h2>
26
27<p>The following example creates a button in the browser toolbar. When the button is clicked, the title of the current tab is retrieved. Then a search is performed in a new tab, using the title as the search query.</p>
28
29<pre><code>//
30// The background process (e.g. index.html) 
31//
32
33// Specify the properties of the button before creating it.
34var UIItemProperties = {
35  disabled: false,
36  title: "Example extension",
37  icon: "images/icon_18.png",
38  onclick: function() {
39    // Get the current tab as a BrowserTab object
40    var thisTab = opera.extension.tabs.getSelected();
41    
42    // Get the title of the tab's document and encode special characters
43    var title = encodeURIComponent(thisTab.title);
44    
45    // Create a tab searching DuckDuckGo for the specified title
46    var tabProps = {
47      url: 'http://duckduckgo.com/?q=' + title
48    }
49    opera.extension.tabs.create(tabProps);
50  }
51};
52
53// Create the button and add it to the toolbar.
54var button = opera.contexts.toolbar.createItem( UIItemProperties );  
55opera.contexts.toolbar.addItem(button);</code></pre>
56
57
58</body>
59</html>