【发布时间】:2023-03-16 01:33:01
【问题描述】:
大家早上好。我有以下问题:
$(document).ready(function(){
$("#actContentToGet").load(function(){
var htmlCODE = document.getElementById('actContentToGet').contentWindow.document.body;
var elements = [];
var z = 1;
function alterContent(htmlCODE){
$("#createdDivs").html("");
htmlCODE.$("*").each(function(){
alert("w");
if($(this).attr("rel")!="nbta"){
var style = '#div' + z + ' style: ' + 'display:block; width:' + $(this).outerWidth( true ) + 'px; height:' + $(this).outerHeight( true ) + 'px; position:absolute; top:' + $(this).position().top + 'px; left:' + $(this).position().left + 'px; cursor:pointer; z-index:' + $(this).parentNumber() + ';';
var newDiv = '<div name="maskBox" id="div' + z + '" class="' + $(this).attr("id") + '" style="display:none;"> </div>';
$("#createdDivs").append(newDiv);
$("#div" + z).attr("style", style);
z++;
}
});
}
});
});
我不知道该怎么做,但如果你明白我的意思,我希望能够使用 iframe 中的内容使用$("*").each()?
我使用htmlCODE.$("*").each(function(){ htmlCODE 未定义
非常感谢任何帮助
【问题讨论】:
-
只是为了让您知道这只是完整代码的 sn-p,并且该函数在其他地方被调用
-
我尝试过
var htmlCODE = document.getElementById('actContentToGet').contentWindow.document.body.getElementsByTagName("*"); var z = 1; function alterContent(htmlCODE){ $("#createdDivs").html(""); $(htmlCODE).each(function(){ alert("w");,但效果很好,但萤火虫uncaught exception: [Exception... "Could not convert JavaScript argument arg 0" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://localhost/www.actwebdesigns.co.uk(Aug2009)/web-design-mansfield/jquery-user-interface-cms/js/jquery-1.3.1.js :: anonymous :: line 797" data: no] Line 0 -
成功了,但是在firebug中发生了错误
标签: javascript jquery iframe