admin管理员组

文章数量:1419182

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.

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.

Share Improve this question asked Nov 22, 2013 at 20:04 Vlad VladVlad Vlad 1322 silver badges13 bronze badges 5
  • 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 Commented Nov 22, 2013 at 20:14
  • @RocketHazmat , browser's tab. – Vlad Vlad Commented Nov 22, 2013 at 20:16
  • What browser are you making an extension for? – gen_Eric Commented Nov 22, 2013 at 20:18
  • Firefox at the moment. – Vlad Vlad Commented Nov 22, 2013 at 20:19
  • 2 Firefox extensions use a different method of accessing tab titles. For Firefox, see: addons.mozilla/en-US/developers/docs/sdk/latest/modules/sdk/… (Chrome is petently different) – gen_Eric Commented Nov 22, 2013 at 20:24
Add a ment  | 

1 Answer 1

Reset to default 3

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/56deD/

http://jsfiddle/56deD/show/

本文标签: javascriptCannot get tab titleStack Overflow