我們有一個應用程序,我們無法觸摸源代碼。這就是爲什麼我不能將JavaScript代碼注入iframe。我試圖操縱的jQuery和JavaScript的圖像按鈕SRC如下:更改動態創建的iframe的內容
// there isn't id of the iframe so I used to catch by tag
$("input:image", window.parent.frames[0].document).each(function() {
$(this).attr("src", "http://" + document.location.hostname + "/theme/img/buttonDownArrow.png")
});
// other attempt
document.getElementsByTagName('iframe').onload = function() {
$("input:image", window.parent.frames[0].document).each(function() {
$(this).attr("src", "http://" + document.location.hostname + "/theme/img/buttonDownArrow.png")
});
}
,但沒有發生。在iframe加載正常後,當我在控制檯中嘗試以上代碼時。我把源代碼放在頁面的末尾,但沒有任何事情發生。反正有沒有操縱加載的iframe內容?
它是在同一個域。 –