3

I am working on a browser extension for which I need to know the current tab title. I manage to find the title from the the HTML page code but, from after documenting more about this I have found that there are easier ways to do this.

I have tried the following ways:

selectedTabTitle = $(ui.tab).text(); 

and

selectedTabTitle = document.title;

but neither work. I must note that I am using kango-framework to make this extension.

Vlad Vlad
  • 132
  • 2
  • 13
  • What "tab" are you talking about? Your 2 examples are *COMPLETELY* different! One is about jQuery UI tabs and the other is the browser's tab. What *exactly* are you trying to get? Where are you trying to access it? What is `ui`? – gen_Eric Nov 22 '13 at 20:14
  • @RocketHazmat , browser's tab. – Vlad Vlad Nov 22 '13 at 20:16
  • What browser are you making an extension for? – gen_Eric Nov 22 '13 at 20:18
  • Firefox at the moment. – Vlad Vlad Nov 22 '13 at 20:19
  • 2
    Firefox extensions use a different method of accessing tab titles. For Firefox, see: https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/sdk/tabs.html (Chrome is competently different) – gen_Eric Nov 22 '13 at 20:24

1 Answers1

2

document.title should work or $('title').text()

are you maybe working with iframes? In that case the title of the iframe will be returned.

here an example:

first one shows the code, second one, so that it is not launched in an iframe

http://jsfiddle.net/56deD/

http://jsfiddle.net/56deD/show/

cytofu
  • 873
  • 9
  • 17