請參閱下面2個HTML頁面,我在iFrame裏面有1個頁面調用其他頁面。 我確實需要什麼,我想在「iframe.html」中可以看到文本字段。當我在該輸入框中寫入內容時,該值應該實時取值href =「」如何設置實時輸入值以通過iFrame鏈接?
說明: iframe.html頁面是純html頁面。我無法在該頁面中使用jquery。我必須從index.html頁面訪問該頁面。
我已經嘗試了一些jQuery代碼,但只有我寫了函數。
這是index.html頁面。
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<iframe src="iframe.html" id="myframe"></iframe>
<script type="text/javascript">
$($("#myframe").contents().find('body')).on("click", 'a[href="#editable-link"]', function(e) {
});
</script>
</body>
</html>
這是「iframe.html」頁面。
<html>
<head>
<input type="text" placeholder="Enter URL">
<a href="" id="editable-link">Read More</a>
</body>
</html>
誰能幫我解決這個問題。這將非常有幫助。 在此先感謝。
的可能重複的[jQuery的/ JavaScript的:一個iframe的訪問內容(http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an- iframe) – Josh
嗨, 但我仍然很困惑如何做到這一點。 –