PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms 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
Possible License(s): MIT, Apache-2.0
  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. <p><a href="../index.html">&laquo; Documentation Home</a></p>
  11. <h1>BrowserTab.title</h1>
  12. <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>
  13. <h2>Description:</h2>
  14. <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>
  15. <h2>Syntax:</h2>
  16. <p><code>readonly string title // maps to document.title</code></p>
  17. <h2>Example:</h2>
  18. <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>
  19. <pre><code>//
  20. // The background process (e.g. index.html)
  21. //
  22. // Specify the properties of the button before creating it.
  23. var UIItemProperties = {
  24. disabled: false,
  25. title: "Example extension",
  26. icon: "images/icon_18.png",
  27. onclick: function() {
  28. // Get the current tab as a BrowserTab object
  29. var thisTab = opera.extension.tabs.getSelected();
  30. // Get the title of the tab's document and encode special characters
  31. var title = encodeURIComponent(thisTab.title);
  32. // Create a tab searching DuckDuckGo for the specified title
  33. var tabProps = {
  34. url: 'http://duckduckgo.com/?q=' + title
  35. }
  36. opera.extension.tabs.create(tabProps);
  37. }
  38. };
  39. // Create the button and add it to the toolbar.
  40. var button = opera.contexts.toolbar.createItem( UIItemProperties );
  41. opera.contexts.toolbar.addItem(button);</code></pre>
  42. </body>
  43. </html>