Let put it in other ways, as it looks like you understood nothing form what
Logic Ali told you
1. There is no
getElementByName() method in JavaScript. There is
getElementsByName(), and it returns a
collection, not a single element. Or you may use
getElementById() instead.
name and
id are not the same thing.
2.
name and
id must start with a letter. Thus: id="2" and name="2" are HTML illegal.
3. window.frames[2] means the second frame/iframe (counted from top to bottom) window.frames['2'] means nothing, as I said, because name can not start with a digit.
4. window.frames[] is the reference of the iframe object, not the reference of the document loaded in the iframe.
So:
Code:
document.getElementById('valid_Iframe_Id').contentWindow.document.getElementsByName('msgtitle')[0].value
But it depends also on which kind of element has the name "msgtitle". If it is a form's element, it will work. If not, you'd better give that object an id, and use getElementById() instead.