0
我試圖將腳本& HTML插入到iframe中。我的問題是我可以將HTML追加到iframe,但我不能追加它,並保持iframe的來源。JQuery插入腳本和HTML到Iframe中
最終的目標是將HTML加載到iframe源文件中並覆蓋。請指教。 我覺得我在這一點上有點偏離。
$(function() {
var $frame = $('<iframe class="viewTrackingFrame" id="viewframe" src="https://www.google.com" width="100%" height="100%" style="width:100%; height:100%;position:relative;">');
$('body').html($frame);
setTimeout(function() {
var doc = $frame[0].contentWindow.document;
var $body = $('body',doc);
$body.html('<h1>Test</h1>');
$body.html('<div id="cursor" style="position:absolute;style:z-index:999999;"><img width="80" src="/assets/img/cursor_blue.png" /></div>');
$body.html('<p id="test" style="z-index:9999999;">The queue length is: <span></span></p>');
}, 1);
});
這是一個好主意,你可以把它與你插入HTML後添加源工作?現在將src添加到這個例子會是一個例子嗎? –