[Project_owners] Problems capturing the title of a webpage.

- EStaticD - estaticd at yahoo.com
Thu Jan 20 01:30:30 EST 2005


Hello everyone.

I am trying to capture the title of the current page that is open and
pass that to a function.

When testing either "window.title" versus
"getBrowser().mCurrentTab.label" variables, usually the window.title
works.

Unfortunately there are two separate problems with window.title.
1) It returns " - Mozilla Firefox" at the end, which although not
difficult to remove, is annoying.
2) Sometime returns variables set in the webpage.  Example:  On one
page I had been testing with, in the CSS tag portion of the page,
title=v4 was set as a variable in the html.  window.title returned
"v4" without the mozilla prefix at the end.  Due to this
bug/feature/etc, I feel that using window.title is not viable.

The getBrowser().mCurrentTab.label variable also has a couple issues,
although I had no problems.  I found out after having someone else
test a build for me, that he did not use tabbed browsing very often. 
Thus, this variable returned a null or undefined value.  No good.

After the tabbed browsing is "initialized", by opening up a second
webpage in another tab, it does return the proper values, even if all
tabs are closed, and only one tab open.

There are a couple solutions that I see so far.  Suggest that people
"initialize" tabbed browsing by default by unticking the advanced
option to "Hide the tab bar when only one web site is open", which
allows me to use use getBrowser().mCurrentTab.label variable all the
time.  If this is done, or if the user inits tabbed browsing by hand,
it always works the way I would expect.

Otherwise I could use window.title and parse the mozilla suffix, and
check for a null value, and if I find a null value, just fudge the
output?  I would like a better solution than what I can think of.

Regards,
Wayne

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Project_owners mailing list