From an HTML Document Object Model point of view, frames are rather odd creatures because they are essentially HTML documents within HTML documents. Consider for a moment the fact that it is possible to have more than one document at a time. For example, the following is perfectly legal:
It refers to the body of the document in the frame with an index of 1. This has a tendency to throw off quite a number of people, probably because it is a "wheels within wheels" kind of relationship, a bit tough to grasp the first time around. There is also the added complexity that if the script is executing in a frame itself, it could quite be playing with either the parent document or a sibling document, or even the child of a sibling. The important thing to remember is that anything that can be done with the current document can also be done with another document.