I have this: var randomnumber=Math.floor(Math.random()*10000); document.write('<iframe name="'+randomnumber+'"></iframe>'); var a = 'frames[\''+randomnumber+'\'].location.href=loc'; eval(a); When I execute it I get: Error: frames['1515'] has no properties Where '1515' is obviously the random number I am generating. Whats the issue? It should work... it works if I change that to a fixed value like: document.write('<iframe name="test"></iframe>'); frames['test'].location.href=loc; Anyone know why this is happening?
I have doubt that numbers are the problem which cannot be name or id of the object. make following change: Which will result in object name to be valid. regards