getElementById problem in Google Chrome

前端 未结 2 2048
有刺的猬
有刺的猬 2021-01-19 01:27

I have this simple line

alert(window.parent.frames[0].document.getElementById(\'textToSearch\').value);

I have 2 frames, first with a text

2条回答
  •  再見小時候
    2021-01-19 02:16

    Use contentWindow.document instead of document:

    var frame = window.parent.frames[0].contentWindow;
    alert(frame.document.getElementById('textToSearch').value);
    

    You can also just use contentDocument for most browsers, but not Internet Explorer 7 or older.

    • contentWindow - MSDN

提交回复
热议问题