FUEL/0.2/API/Browser
Jump to navigation
Jump to search
Sample Code:
Open, and activate, a new tab
App.browser.open("http://google.com/").active = true;
Open, and activate, a tab just after the current tab
var tab = App.browser.open("http://google.com/"); App.browser.insertBefore( tab, App.browser.activeTab.next ); tab.active = true;
or:
var tab = App.browser.open("http://google.com/"); tab.index = App.browser.activeTab + 1; tab.active = true;
Move the active tab to be the first tab
App.browser.insertBefore( App.browser.activeTab, App.browser.tabs[0] );
or:
App.browser.activeTab.index = 0;
Close the active tab
App.browser.activeTab.close();
Do something when the active tab loads
App.browser.activeTab.events.addListener( "load", function(){ this.query("#foo div") });
Change the URL in the active tab
App.browser.activeTab.url = "http://mozilla.org/";
Close all Google-related tabs
App.browser.tabs.forEach(function(tab){ if ( tab.url.match(/google/) ) tab.remove(); });
Re-use a tab, or open a new one
var url = "http://google.com/"; App.browser.tabs.some(function(tab){ if ( tab.url == url ) return tab.active = true; }) || App.browser.open( url ).active = true;
Stop the user from opening any new tabs
App.browser.events.addListener( "TabOpen", function(e){ e.target.close(); });
Browser
Properties:
tabs
is anArray<Tab>
events
is anEvents
activeTab
is aTab
Methods:
insertBefore( Tab, Tab )
append( Tab )
open( String )
returns aTab
Tab
Properties:
browser
is aBrowser
events
is anEvents
document
is aDOMDocument
window
is aDOMWindow
active
is aBoolean
next
is aTab
prev
is aTab
url
is aString
(Getter/Setter)index
is aNumber
(Getter/Setter)
Methods:
query( String )
returns anArray<DOMElement>
focus()
close()