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

Language HTML Lines 59
MD5 Hash cd1b486840bf1ee39568e661912058b2
Repository https://github.com/richtr/operaextensions.js.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
  <title>Opera Extensions API Documentation</title>
  <link rel='stylesheet' href='../resources/markdown8.css'/>
  <meta charset='utf-8'>
  <meta charset='utf-8'>
</head>
<body>

<p><a href="../index.html">&laquo; Documentation Home</a></p>

<h1>BrowserTab.title</h1>

<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>

<h2>Description:</h2>

<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>

<h2>Syntax:</h2>

<p><code>readonly string title // maps to document.title</code></p>

<h2>Example:</h2>

<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>

<pre><code>//
// The background process (e.g. index.html) 
//

// Specify the properties of the button before creating it.
var UIItemProperties = {
  disabled: false,
  title: "Example extension",
  icon: "images/icon_18.png",
  onclick: function() {
    // Get the current tab as a BrowserTab object
    var thisTab = opera.extension.tabs.getSelected();
    
    // Get the title of the tab's document and encode special characters
    var title = encodeURIComponent(thisTab.title);
    
    // Create a tab searching DuckDuckGo for the specified title
    var tabProps = {
      url: 'http://duckduckgo.com/?q=' + title
    }
    opera.extension.tabs.create(tabProps);
  }
};

// Create the button and add it to the toolbar.
var button = opera.contexts.toolbar.createItem( UIItemProperties );  
opera.contexts.toolbar.addItem(button);</code></pre>


</body>
</html>
Back to Top