我有一個表單,其中我已經採取了一個文本字段,並且還在其中稱爲iframe,並且在iframe中有一個Name
的文本字段。我想在使用JavaScript/jQuery的鍵盤上將Name
顯示到我的表單文本字段中。我的意思是,我已經進入到Name
文本字段中的東西,它會顯示在我的輸入字段中。
如何獲取iframe內的文本字段中的文本是否跨域?
我打電話從其他domain.I iframe中使用了下面的代碼
<script>
var iframe = document.getElementById('progressive');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var usernameTextBox = innerDoc.getElementById('ApplicantInfo1_FirstName');
usernameTextBox.focus();
</script>
我得到 錯誤:語法錯誤:語法錯誤 源文件:文件:/// C :/Users/monika.m/Desktop/iframe.html Line:30 源代碼: var windowjQuery = $('#progressive')[0] .contentWindow。$; – Rash
@拉什,更新了答案。 –