DomAPI Home
DomAPI
Build: 4.0 BETA
Topic: Use core from IFRAME PageControl

  alberto registered v3 wrote on Tuesday 12/16/03 at 4:36 AM (PST)  
 

Hello,

We've created a pagecontrol with several IFRAMEs in it. In each of these IFRAMEs we use other DomAPI controls. Up to now there is a line like these on each IFRAME begining:

 <script type="text/javascript" src="/js/ui/core.js"></script>


The problem is IE seems to load DomAPI each time, so it keeps getting more and more memory everytime an IFRAME is reloaded.

Is there a way to create the DomAPI components of the IFRAMEs using the core object located on the page where the pagecontrol is created?

We have tried to do a getCore() function, and get the core on each IFRAMEs begining, like this:
var core = top.getCore();

but it does not work (causes an error when core.loadUnit is called).

Thanks in advance for your help.

 
    RSS feed of forum  
  Darin Kadrioski registered v4 wrote on Tuesday 12/16/03 at 7:24 AM (PST)  
 

Assuming they are all on the same domain, just prefix each call to core by top.core

or, along the lines you were going, use core = top.core

there is no getCore() function.

 
    RSS feed of forum  
  alberto registered v3 wrote on Tuesday 12/16/03 at 7:37 AM (PST)  
 

I know there is no getCore function, this method has been created by us to get the core var from the top, the same you suggest with top.core (the function is on the main window):

function getCore() {
 return(core);
}


Anyway, the problem persists. If we do what you say there is an error ("Error: 'core' is undefined") on one of the units we use (listbox) on the IFRAME. Can you help us? Thanks!

 
    RSS feed of forum  
  Darin Kadrioski registered v4 wrote on Tuesday 12/16/03 at 8:29 AM (PST)  
 

Have you tried parent.core?

 
    RSS feed of forum  
  alberto registered v3 wrote on Tuesday 12/16/03 at 9:05 AM (PST)  
 

I think the problem is not the core var, since with this test copyright is showed correctly:

index.html:
<html>
<head>
<script type="text/javascript" src="./js/ui/core.js"></script>
<script type="text/javascript">
core.loadUnit("reflow");
core.loadUnit("pagecontrol");

function getCore() {
return(core);
}

onload=function() {
var tabs = Pagecontrol({x:0, y:0, w:0, h:0});
tabs.reflowAdd({l:'0%', t:'5%', w:'75%', h:'95%', pad:4});
tabs.addPage("Test", "IFRAME", "index2.html");
core.reflow.render();
}
</script>
</head>
<body>
</body>
</html>


index2.html:
<html>
<head>
<script type="text/javascript">
var core = top.getCore();
alert(core.copyright);
core.loadUnit("reflow");
core.loadUnit("listbox");
onload=function() {
var data = Listbox({x:0, y:0, w:0, h:0});
data.reflowAdd({l:'0%', t:'60', w:'100%', b:'100%', pad:2});
data.addItem({value: '1', text:'1'});
data.addItem({value: '2', text:'2'});
core.reflow.render();
}
</script>
</head>
<body>
</body>
</html>

 
    RSS feed of forum  
  Simon G registered v4 wrote on Tuesday 12/16/03 at 2:20 PM (PST)  
 

Hi Alberto,

By my experiments, the answer to "Is there a way to create the DomAPI components of the IFRAMEs using the core object located on the page where the pagecontrol is created?" - is no (unfortunately).

Javascript objects can be referenced between parent and iframes, however having the domAPI resident in the parent, and creating components in the child IFRAME simply doesn't work. Theres a work arounds needed to allow IE to create DOM objects in the parent and then attach them in the child. Then the domAPI widgets all need to be checked to ensure they accomodate this workaround (as many widgets create object components themselves directly).

Do a search through the forum for iFrame and then check my post "Single load domApi, multiple iframes". This talks about the same problem (unfortunately I got a bit wordy!) This got little interest so my guess is nobody was really trying it.

Cheers,
Simon.

 
    RSS feed of forum  
  alberto registered v3 wrote on Wednesday 12/17/03 at 3:20 AM (PST)  
 

Thanks for the answer Simon!

Now we are like at the beginning...
Darin, any help?

 
    RSS feed of forum  
  Darin Kadrioski registered v4 wrote on Wednesday 12/17/03 at 7:33 AM (PST)  
 

Nope. What Simon is saying makes perfect sense.

The only thing I can think of would be to have a variable named core.window, and prefix all calls to the DOM, everywhere in the Library, with that refererence. core.window could default to the window it resides in, but in a case such as yours, you'd have to point it at a particular window before every call your code makes.

That would be way too messy a mod at this point though.

It's too bad that within a function you cannot tell what window the caller is in, then it could be automatic.
Darin Kadrioski Darin Kadrioski
support@domapi.com

 
    RSS feed of forum  
You could respond to this post if you were logged in.
DHTML by www.domapi.com