PDA

View Full Version : Check to see if tab already open



gibberish
8 Jan 2007, 1:10 AM
I have this code below. and I would like to check to see if a user already has a tab with the ID already open. If so goto that tab. If they do not have a tab with the ID create a new tab.

Not sure if ID is being passed.

also how do I search for a tab with a give ID?

showFrame : function(myID,companyName){

var iframe = YAHOO.ext.DomHelper.append(document.body,
{tag: 'iframe', frameBorder: 0, src: 'reports/advertiser_profile.php?companyID=' + myID});
var panel = new YAHOO.ext.ContentPanel(iframe,
{title: (companyName), fitToFrame:true, closable:true , id: myID});
layout.add('center', panel);

}


Thanks for any help.

Gibberish

tryanDLS
8 Jan 2007, 7:36 AM
Please make an attempt to read the documentation before posting. Did you try getTab(id)?

gibberish
8 Jan 2007, 11:23 AM
I did read the manual, as I understand it you can't use getID() with Iframes. I am new to YUI and if I used the wrong terms, please excuse.

I am using iFrames to pop open a new tab.

By using the code above it opens a new iframe. I would like to get the ID of that iFrame.


If this is possible please let me know.

Thanks

--

Gibberish

masudkuet
8 Jan 2007, 10:06 PM
use the following code...


var panelExists = layout.getRegion('center').getPanel('frame-' + myID);

if(!panelExists){

var iframe = YAHOO.ext.DomHelper.append(document.body,
{tag: 'iframe', id: 'frame-' + myID, frameBorder: 0, src: 'reports/advertiser_profile.php?companyID=' + myID});

var panel = new YAHOO.ext.ContentPanel(iframe,
{title: (companyName), fitToFrame:true, closable:true , id: myID});
layout.add('center', panel);

}
else{

layout.showPanel(panelExists);

}

gibberish
9 Jan 2007, 6:12 AM
masudkuet, Thank you that worked perfectly.



--

Gibbersih