Javascript variables and frames

wxdqz

New Member
Hi,

I am having problems using/setting a javascript variable.


Consider the following function that I am using:

function getLayer(id,framename) {
if (framename == "top.index_main.main")
return top.index_main.main.document.all[id];
if (framename == "top.index_main.news_main")
return top.index_main.news_main.document.all[id];
if (framename == "top.index_nav")
return top.index_nav.document.all[id];
if (framename == "top.index_main")
return top.index_main.document.all[id];
}

However, if I try to use the following, which would seem to me to be the obvious way to do it, I get errors:

function getLayer(id,framename) {
return framename.document.all[id];
}

My list of frame names is growing, and I do not want to have to use the first method. Is there something that I am doing wrong in my second method to explain why it wont work?

Any suggestions apreciated!
 
Back
Top