The DFrameCollector class has no public constructor. Only one object, the DFrameCollector object, is created from this class. This is automatically done when the dFrameAPI loads.
The DFrameCollector object manages closed DFrames in order to reuse them.
function openDFrame(urlForDFrame) {
//define a key for this kind of dFrame
var key = 'keyForDFrameOfThisType'
//look for a dFrame with this key in the dFrameCollector
dFrame = DFrameCollector.find(key)
//if not found: create a new dFrame
if ( !dFrame ) dFrame = instantiateDFrame(key)
dFrame.setURL(urlForDFrame)
}
function instantiateDFrame(key) {
var dFrame = new DFrame(parameters)
dFrame.addButton('Close', 'this.closeFrame()')
//register the dFrame in the dFrameCollector for reuse
DFrameCollector.register(dFrame, key)
return dFrame
}
Demo
file: setTarget.html
Run the example
See the source code
var dFrame = new DFrame(parameters);
DFrameCollector.register(dFrame, 'keyForThisDFrame')
DFrame.register(dFrame, key)
dFrame:A DFrame object
key
String: The key that will be used to find a DFrame with the find method.
No return value
var dFrame = DFrameCollector.find(dFrame, 'keyForThisDFrame')
if (!dFrame) var dFrame = new DFrame(parameters)
dFrame.setURL(url)
DFrame.find(key)
key
String: The key that was used to register a DFrame in the DFrameCollector.
DFrame object
When a DFrame is closed it is not destroyed but only hidden. Closed DFrames can be reused if they are registered in the DFrameCollector.
In order to store many kinds of DFrames in the DFrameCollector and retrieve only DFrames of one category a key is added to DFrames when they are registered. The find method will look for only DFrames having the same key.
When a DFrame is found by the find method it is automatically removed from the DFrameCollector and will be stored again in it when the closeFrame method will be used.