You must have tried to customize the Top content area of your standard entities.
Sometimes you must have found it to be very difficult to refer to the Top Content area in order to do some customizations on it. Even if everything is right with the script you have written and it also doesn’t return any error, then also you are not able to refer the fields from the top content.
Well, as you thought there is nothing wrong with the script you have written, but the way you have written it.
Basically, in order to refer to the Top Content Area, you must first find an object for the same. For this you can use the following statement in your code.
Tcontentobj = parent.frames.document.activeElement;
Tcontenthtml = Tcontentobj.innerHTML;
As, now you have the inner HTML for the top content you can change it according to your requirement and force the innerHTML to be the one you have created above to see the changes you made