Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Firefox plugin - Not able to hide the tab browser

15 views
Skip to first unread message

Pradeep Dewda

unread,
Mar 24, 2013, 1:36:35 AM3/24/13
to
Hi,

I am developing a plugin for firefox. In which i have to open a hidden tab and access its content through javascript and close it afterwards.

Following is the code i am using for accessing content of a tab:

var newTabBrowser = gBrowser.getBrowserForTab(gBrowser.addTab("www.kayak.com/flights#/BOM-ORL/2013-05-14/2013-06-19"));
var contentdata="";
newTabBrowser.addEventListener("load", function () {
contentdata=contentdata+newTabBrowser.contentDocument.body.innerHTML;
load=load+1;
if(load==5) {
var DOMPars = new DOMParser();
var dom = DOMPars.parseFromString(contentdata, "text/html");
var priceNode=dom.getElementById('low_price');
return priceNode.innerHTML;
}
}, true);

How can i hide the above tab in the browser?

Neil

unread,
Mar 25, 2013, 5:24:17 AM3/25/13
to
Pradeep Dewda wrote:

>Following is the code i am using for accessing content of a tab:
>
>var newTabBrowser = gBrowser.getBrowserForTab(gBrowser.addTab("www.kayak.com/flights#/BOM-ORL/2013-05-14/2013-06-19"));
>var contentdata="";
>newTabBrowser.addEventListener("load", function () {
> contentdata=contentdata+newTabBrowser.contentDocument.body.innerHTML;
> load=load+1;
> if(load==5) {
> var DOMPars = new DOMParser();
> var dom = DOMPars.parseFromString(contentdata, "text/html");
> var priceNode=dom.getElementById('low_price');
> return priceNode.innerHTML;
> }
> }, true);
>
>How can i hide the above tab in the browser?
>
>
I assume the reason you can't use XHR is that you need scripts to run in
the page.

I guess your best best is to create a hidden <iframe> element. Set the
type="content" and collapsed="true" attributes before adding it to the
DOM. See
https://developer.mozilla.org/en-US/docs/Code_snippets/HTML_to_DOM
(scroll down to Using a hidden iframe element to parse HTML to a
window's DOM).

But why are you parsing the result of innerHTML instead of locating the
DOM node directly?

--
Warning: May contain traces of nuts.
0 new messages