views:

54

answers:

1

Hi,

We are using too many iframes in out web application. In these iframes we load the pages which may also contains iframes and so on up to N level.

Right now i'm using recursive function to find out the required iframe object in JavaScript. It works fine, The issue is when we create large dynamic pages which may contains up to 1000 iframes in it. In this case my recursive function takes too much time to find the required iframe object.

How i can overcome this issue or these is any alternative of recursion in JavaScript.

Thanks

A: 

try registering all the iframes into an array immediately before onload (while the user is still waiting). This way you dont have to assemble all the iframes and only then go thru them. at the bottom of your page...

< /html>
< script>iframes=document.getElementsByTagName("iframe")< /script>

Still not really sure how you are identifying each iframe - so if you are searching for a particular id or src - try this as a setup array

< /html>
< script>
iframes=document.getElementsByTagName("iframe")
var iframe_stuff=[]
var i=0
while(iframes[i])
{
iframe_stuff[i]=[]
iframe_stuff[i]["id"]=iframes[i].id
iframe_stuff[i]["src"]=iframes[i].src
i++
}< /script>

So when you need to go thru your iframes the list array is ready. Also remember to use 'break' after you found the iframe you want. If your found iframe is at number 4, break will stop the search there and not check the rest...

Johnny Darvall